diff --git a/src/org/openjdk/asmtools/jasm/JasmTokens.java b/src/org/openjdk/asmtools/jasm/JasmTokens.java index 8471b1c..e3d071c 100644 --- a/src/org/openjdk/asmtools/jasm/JasmTokens.java +++ b/src/org/openjdk/asmtools/jasm/JasmTokens.java @@ -22,6 +22,7 @@ */ package org.openjdk.asmtools.jasm; +import java.util.Arrays; import java.util.EnumSet; import java.util.Optional; @@ -417,6 +418,16 @@ public static Optional get(String parsekey, KeywordType ktype) { findFirst(); } + /** + * Checks that this enum element is in an enum list + * + * @param tokens the list of enum elements for checking + * @return true if a tokens list contains this enum element + */ + public boolean in(Token... tokens) { + return (tokens == null) ? false : Arrays.asList(tokens).contains(this); + } + // By default, if a KeywordType is not specified, it has the value 'TOKEN' Token(Integer val, String print, String parsekey, EnumSet ttype) { this(val, print, parsekey, null, ttype, KeywordType.TOKEN); diff --git a/src/org/openjdk/asmtools/jasm/Parser.java b/src/org/openjdk/asmtools/jasm/Parser.java index f22755b..5e9586e 100644 --- a/src/org/openjdk/asmtools/jasm/Parser.java +++ b/src/org/openjdk/asmtools/jasm/Parser.java @@ -433,13 +433,18 @@ ConstCell parseMethodHandle(SubTag subtag) throws Scanner.SyntaxError, IOExcepti * ldc Dynamic REF_newInvokeSpecial:InterfaceMethod LdcConDyTwice."": * ldc Dynamic REF_invokeInterface:LdcConDyTwice."": * ldc Dynamic REF_newInvokeSpecial:Method LdcConDyTwice."": + * ldc MethodHandle REF_newInvokeSpecial:InterfaceMethod LdcConDyTwice."": + * ldc MethodHandle REF_invokeInterface:LdcConDyTwice."": + * ldc MethodHandle REF_newInvokeSpecial:Method LdcConDyTwice."": + * invokedynamic MethodHandle REF_invokeStatic:Method java/lang/invoke/StringConcatFactory.makeConcatWithConstants: + * invokedynamic MethodHandle REF_invokeStatic:java/lang/invoke/StringConcatFactory.makeConcatWithConstants * .... * @param position the position in a source file * @param defaultTag expected reference_index tag (Method or InterfaceMethod) * @param defaultTag 2nd expected reference_index tag (Method or InterfaceMethod) */ private void checkReferenceIndex(int position, ConstType defaultTag, ConstType default2Tag) { - if (scanner.token != COLON) { + if ( ! scanner.token.in(COLON, SEMICOLON) ) { if (default2Tag != null) { env.error(position, "wrong.tag2", defaultTag.parseKey(), default2Tag.parseKey()); } else {