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

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

@ -331,27 +331,40 @@ d2l: {
ConstantPool.ConstCell refCell; ConstantPool.ConstCell refCell;
ConstantPool.ConstCell subtagCell; ConstantPool.ConstCell subtagCell;
SubTag subtag; SubTag subtag;
// MethodHandle [INVOKESUBTAG|INVOKESUBTAG_INDEX] : CONSTANT_FIELD | [FIELDREF|METHODREF|INTERFACEMETHODREF]
if (scanner.token == Token.INTVAL) { if (scanner.token == Token.INTVAL) {
// INVOKESUBTAG_INDEX
// Handle explicit constant pool form // Handle explicit constant pool form
subtag = subtag(scanner.intValue); subtag = subtag(scanner.intValue);
subtagCell = new ConstantPool.ConstCell(subtag.value()); subtagCell = new ConstantPool.ConstCell(subtag.value());
scanner.scan(); scanner.scan();
scanner.expect(Token.COLON); scanner.expect(Token.COLON);
if (scanner.token != Token.CPINDEX) { if (scanner.token == Token.CPINDEX) {
env.traceln("token=" + scanner.token); // CONSTANT_FIELD
env.error(scanner.pos, "token.expected", "<CPINDEX>"); int cpx = scanner.intValue;
throw new Scanner.SyntaxError(); 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 { } else {
// INVOKESUBTAG : REF_INVOKEINTERFACE, REF_NEWINVOKESPECIAL, ...
// normal JASM // normal JASM
subtag = parser.parseSubtag(); subtag = parser.parseSubtag();
subtagCell = new ConstantPool.ConstCell(subtag.value()); subtagCell = new ConstantPool.ConstCell(subtag.value());
scanner.expect(Token.COLON); 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); obj = new ConstantPool.ConstValue_Pair(tag, subtagCell, refCell);
} catch (IOException e) { } catch (IOException e) {