Skip to content

Question about AccessUtill::replaceAccessFlags #157

@xxDark

Description

@xxDark

Greetings.
The case is as follows:

package X.a;

final class ComputeRuntimeVersionImpl implements ComputeRuntimeVersion {
	final AtomicInteger value = new AtomicInteger(8);

	@Override
	public void accept(int version) {
		int current;
		do {
			current = value.get();
		} while (version < current && !value.weakCompareAndSetVolatile(current, version));
	}

	@Override
	public Runtime.Version get() {
		return Runtime.Version.parse(Integer.toString(value.get()));
	}
}

Notice that the value field is not private.
All classes are repackages to package X. Now, after AccessFixer does its job, the field access will be changed to private, but for some reason final modifier is dropped.
https://github.com/Guardsquare/proguard-core/blob/master/base/src/main/java/proguard/classfile/util/AccessUtil.java#L97
If I declare the field as private myself, this does not happen.
What is the reason behind dropping the final modifier? I tried to check the git blame, but the commit that added that behavior does not say why it is done. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions