CODETOOLS-7901522 Jasm doesn't allow to create REF_invoke* referring an InterfaceMethod

This commit is contained in:
lkuskov 2019-09-11 13:10:14 -07:00
parent 610805dfe5
commit ba35302fcd
2 changed files with 24 additions and 11 deletions

View File

@ -251,8 +251,8 @@ Other values for TARGET are:
<target name="compileClasses" depends="prepare">
<mkdir dir="${build.classes.dir}"/>
<javac fork="true"
target="1.8"
source="1.8"
target="9"
source="9"
srcdir="${build.src.classes.dir}"
destdir="${build.classes.dir}"
debug="${javac.debug}"

View File

@ -331,27 +331,40 @@ d2l: {
ConstantPool.ConstCell refCell;
ConstantPool.ConstCell subtagCell;
SubTag subtag;
// MethodHandle [INVOKESUBTAG|INVOKESUBTAG_INDEX] : CONSTANT_FIELD | [FIELDREF|METHODREF|INTERFACEMETHODREF]
if (scanner.token == Token.INTVAL) {
// INVOKESUBTAG_INDEX
// Handle explicit constant pool form
subtag = subtag(scanner.intValue);
subtagCell = new ConstantPool.ConstCell(subtag.value());
scanner.scan();
scanner.expect(Token.COLON);
if (scanner.token != Token.CPINDEX) {
env.traceln("token=" + scanner.token);
env.error(scanner.pos, "token.expected", "<CPINDEX>");
throw new Scanner.SyntaxError();
if (scanner.token == Token.CPINDEX) {
// CONSTANT_FIELD
int cpx = scanner.intValue;
refCell = parser.pool.getCell(cpx);
scanner.scan();
} else {
// [FIELDREF|METHODREF|INTERFACEMETHODREF]
refCell = parser.parseMethodHandle(subtag);
}
int cpx = scanner.intValue;
refCell = parser.pool.getCell(cpx);
scanner.scan();
} else {
// INVOKESUBTAG : REF_INVOKEINTERFACE, REF_NEWINVOKESPECIAL, ...
// normal JASM
subtag = parser.parseSubtag();
subtagCell = new ConstantPool.ConstCell(subtag.value());
scanner.expect(Token.COLON);
refCell = parser.parseMethodHandle(subtag);
if (scanner.token == Token.CPINDEX) {
// CODETOOLS-7901522: Jasm doesn't allow to create REF_invoke* referring an InterfaceMethod
// Parsing the case when refCell is CP index (#1)
// const #1 = InterfaceMethod m:"()V";
// const #2 = MethodHandle REF_invokeSpecial:#1;
int cpx = scanner.intValue;
refCell = parser.pool.getCell(cpx);
scanner.scan();
} else {
refCell = parser.parseMethodHandle(subtag);
}
}
obj = new ConstantPool.ConstValue_Pair(tag, subtagCell, refCell);
} catch (IOException e) {