RFR: 8307818: Convert Indify tool to Classfile API [v11]

ExE Boss duke at openjdk.org
Wed Jun 19 21:28:18 UTC 2024


On Wed, 19 Jun 2024 12:04:27 GMT, Oussama Louati <duke at openjdk.org> wrote:

>> An indify tool in j.l.i tests (also in vmTestBase) convert some source-code private static methods with MT_ MH_, and INDY_ prefixes into MethodHandle, MethodType, and CallSite constants.
>> It currently uses ad-hoc code to process class files and intends to migrate to ASM; but since we have the Classfile API, we can migrate to Classfile API instead.
>
> Oussama Louati has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix: fix comments

Formatting nits:

More formatting nits:

test/jdk/java/lang/invoke/indify/Indify.java line 656:

> 654:             for(PoolEntry entry : classModel.constantPool()){
> 655:                 char mark = 0;
> 656:                 if(poolMarks[entry.index()] != 0) continue;

Suggestion:

        boolean initializeMarks() {
            boolean anyMarkChanged = false;
            for (PoolEntry entry : classModel.constantPool()) {
                char mark = 0;
                if (poolMarks[entry.index()] != 0) continue;

test/jdk/java/lang/invoke/indify/Indify.java line 674:

> 672:                     if(poolMarks[memberRefEntry.owner().index()] != 0){
> 673:                         mark = poolMarks[memberRefEntry.owner().index()];
> 674:                     }

Suggestion:

                if (entry instanceof Utf8Entry utf8Entry) {
                    mark = nameMark(utf8Entry.stringValue());
                }
                if (entry instanceof ClassEntry classEntry) {
                    mark = nameMark(classEntry.asInternalName());
                }
                if (entry instanceof StringEntry stringEntry) {
                    mark = nameMark(stringEntry.stringValue());
                }
                if (entry instanceof NameAndTypeEntry nameAndTypeEntry) {
                    mark = nameAndTypeMark(nameAndTypeEntry.name(), nameAndTypeEntry.type());
                }
                if (entry instanceof MemberRefEntry memberRefEntry) {
                    poolMarks[memberRefEntry.owner().index()] = nameMark(memberRefEntry.owner().asInternalName());
                    if(poolMarks[memberRefEntry.owner().index()] != 0){
                        mark = poolMarks[memberRefEntry.owner().index()];
                    }

test/jdk/java/lang/invoke/indify/Indify.java line 678:

> 676:                         if(memberRefEntry.owner().equals(classModel.thisClass())){
> 677:                             mark = nameMark(memberRefEntry.name().stringValue());
> 678:                         }

Suggestion:

                    else {
                        if (memberRefEntry.owner().equals(classModel.thisClass())) {
                            mark = nameMark(memberRefEntry.name().stringValue());
                        }

test/jdk/java/lang/invoke/indify/Indify.java line 686:

> 684:             return anyMarkChanged;
> 685:         }
> 686:         char nameAndTypeMark(Utf8Entry name, Utf8Entry type){

Suggestion:

        }

        char nameAndTypeMark(Utf8Entry name, Utf8Entry type){

test/jdk/java/lang/invoke/indify/Indify.java line 691:

> 689:             String descriptor = type.stringValue();
> 690:             String requiredType;
> 691:             switch (mark){

Suggestion:

            switch (mark) {

test/jdk/java/lang/invoke/indify/Indify.java line 696:

> 694:                 default:  return 0;
> 695:             }
> 696:             if(matchType(descriptor, requiredType)) return mark;

Suggestion:

            if (matchType(descriptor, requiredType)) return mark;

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

PR Review: https://git.openjdk.org/jdk/pull/18841#pullrequestreview-2129054394
PR Review: https://git.openjdk.org/jdk/pull/18841#pullrequestreview-2129056939
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646696601
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646697107
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646697252
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646698327
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646698374
PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1646698432


More information about the core-libs-dev mailing list