Skip to content
Permalink
Browse files
7902913: jasm incorrectly processes the instruction pair: ldc MethodH…
…andle
  • Loading branch information
lkuskov committed May 1, 2021
1 parent 4dc5f0a commit 9e362374fb620c074b42f182c67b5a89617c0a67
Showing 2 changed files with 17 additions and 1 deletion.
@@ -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<Token> 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<TokenType> ttype) {
this(val, print, parsekey, null, ttype, KeywordType.TOKEN);
@@ -433,13 +433,18 @@ ConstCell parseMethodHandle(SubTag subtag) throws Scanner.SyntaxError, IOExcepti
* ldc Dynamic REF_newInvokeSpecial:InterfaceMethod LdcConDyTwice."<init>":
* ldc Dynamic REF_invokeInterface:LdcConDyTwice."<init>":
* ldc Dynamic REF_newInvokeSpecial:Method LdcConDyTwice."<init>":
* ldc MethodHandle REF_newInvokeSpecial:InterfaceMethod LdcConDyTwice."<init>":
* ldc MethodHandle REF_invokeInterface:LdcConDyTwice."<init>":
* ldc MethodHandle REF_newInvokeSpecial:Method LdcConDyTwice."<init>":
* 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 {

0 comments on commit 9e36237

Please sign in to comment.