Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* @test
* @summary Verify CVM8 accepts the legacy Scala 2.11 Methodref encoding for an interface static method
* @compile LegacyInterfaceMethodrefCaller.jasm
* @compile LegacyInterfaceMethodref.java
* @run main/othervm LegacyInterfaceMethodref
* @run main/othervm -Xint LegacyInterfaceMethodref
* @run main/othervm -Xcomp LegacyInterfaceMethodref
* @run main/othervm -XX:-AllowLegacyInterfaceMethodref -DexpectICCE=true LegacyInterfaceMethodref
*/

interface LegacyStaticInterface {
static int value() {
return 42;
}
}

public class LegacyInterfaceMethodref {
public static void main(String[] args) {
boolean expectICCE = Boolean.getBoolean("expectICCE");
try {
int result = LegacyInterfaceMethodrefCaller.call();
if (expectICCE) {
throw new AssertionError("Expected IncompatibleClassChangeError");
}
if (result != 42) {
throw new AssertionError("Unexpected result: " + result);
}
} catch (IncompatibleClassChangeError error) {
if (!expectICCE) {
throw error;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
super public class LegacyInterfaceMethodrefCaller
version 52:0
{
public static Method call:"()I"
stack 1 locals 0
{
invokestatic Method LegacyStaticInterface.value:"()I";
ireturn;
}
}
11 changes: 10 additions & 1 deletion src/hotspot/share/interpreter/linkResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,16 @@ Method* LinkResolver::resolve_interface_method(const LinkInfo& link_info, Byteco
}

// check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref
if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {
#if HOTSPOT_TARGET_CLASSLIB == 8
const bool invalid_tag = !link_info.tag().is_invalid() &&
!link_info.tag().is_interface_method() &&
(!AllowLegacyInterfaceMethodref ||
code != Bytecodes::_invokestatic ||
!link_info.tag().is_method());
#else
const bool invalid_tag = !link_info.tag().is_invalid() && !link_info.tag().is_interface_method();
#endif
if (invalid_tag) {
ResourceMark rm(THREAD);
stringStream ss;
ss.print("Method '");
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,10 @@ const intx ObjectAlignmentInBytes = 8;
"(default) disables native heap trimming.") \
range(0, UINT_MAX) \
\
CLASSLIB8_ONLY(product(bool, AllowLegacyInterfaceMethodref, true, \
"Allow invokestatic to reference an interface static " \
"method with a Methodref constant")) \
\
CLASSLIB8_ONLY(develop(bool, VerifyLatin1NamesOnly, false, \
"Ensure class/method/field names are encoded in Latin1")) \
\
Expand Down
Loading