RFR: 8294966: jdk.jartool sun.tools.jar.FingerPrint uses ASM to parse class jar entries

Mandy Chung mchung at openjdk.org
Thu Mar 9 17:41:36 UTC 2023


On Thu, 15 Dec 2022 14:56:03 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> 8294966: jdk.jartool sun.tools.jar.FingerPrint uses ASM to parse class jar entries
> This patch converts it to use Classfile API.
> 
> Please review.
> Thanks,
> Adam

src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java line 42:

> 40: import jdk.internal.classfile.FieldModel;
> 41: import jdk.internal.classfile.MethodModel;
> 42: import jdk.internal.classfile.attribute.EnclosingMethodAttribute;

this import is unused.

src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java line 282:

> 280:                         fields.add(new Field(fm.flags().flagsMask(),
> 281:                                 fm.fieldName().stringValue(),
> 282:                                 fm.fieldType().stringValue()));

I find it more readable if the parameters to the Field constructor is aligned:

Suggestion:

                        fields.add(new Field(fm.flags().flagsMask(),
                                             fm.fieldName().stringValue(),
                                             fm.fieldType().stringValue()));

src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java line 313:

> 311:         @Override
> 312:         public void visitEnd() {
> 313:             this.nestedClass = this.outerClassName != null;

`this.nestedClass` is updated after the attributes are visited.   Suggest to rename `nestedClass` to `maybeNestedClass` and change `isNestedClass` to:

    public boolean isNestedClass() {
        return attrs.maybeNestedClass && attrs.outerClassName != null;
    }

-------------

PR: https://git.openjdk.org/jdk/pull/11694


More information about the compiler-dev mailing list