-
Bug
-
Resolution: Fixed
-
P3
-
21
-
b10
There are classes (attached to this issue)
public class CTestClass extends CTestSuperClass implements ITestInterfaceA {
public static String ctestString = "CTestClass";
public static long ctestLong = 1l;
}
&&
public class CTestSuperClass {
public static String stringField = "CTestSuperClass";
public static long longField = 100L;
public static String stringField2 = "CTestSuperClass2";
public static long longField2 = 102L;
}
&&
public interface ITestInterfaceA {
String stringField = "ITestInterfaceA";
long longField = 10l;
String stringField3 = "ITestInterfaceA3";
long longField3 = 13L;
}
and test runner that has the sequence of method invocations:
VarHandle vh = MethodHandles.lookup().findStaticVarHandle(CTestClass.class,”longField”, long.class);
// or
VarHandle vh = MethodHandles.lookup().findStaticVarHandle(CTestClass.class,”stringField”, Stirng.class);
// and
VarHandle.VarHandleDesc vhd = vh.describeConstable();
then vhd will erroneously describe : VarHandleDesc[static CTestClass.ctestLong:long] or VarHandleDesc[static CTestClass.ctestString:String]
It happens only if CTestClass has both static fields
otherwise if for example the field String ctestString is removed from the CTestClass.class then vh.describeConstable throws the exception:
java.lang.InternalError: Static field not found at offset
at java.base/java.lang.invoke.VarHandles.getStaticFieldFromBaseAndOffset(VarHandles.java:197)
at java.base/java.lang.invoke.VarHandleLongs$FieldStaticReadOnly.describeConstable(VarHandleLongs.java:410)
Thus VarHandle.describeConstable hasn’t been working since fix ofJDK-8297757
Also any exception thrown by describeConstable should be mentioned in the specification
public class CTestClass extends CTestSuperClass implements ITestInterfaceA {
public static String ctestString = "CTestClass";
public static long ctestLong = 1l;
}
&&
public class CTestSuperClass {
public static String stringField = "CTestSuperClass";
public static long longField = 100L;
public static String stringField2 = "CTestSuperClass2";
public static long longField2 = 102L;
}
&&
public interface ITestInterfaceA {
String stringField = "ITestInterfaceA";
long longField = 10l;
String stringField3 = "ITestInterfaceA3";
long longField3 = 13L;
}
and test runner that has the sequence of method invocations:
VarHandle vh = MethodHandles.lookup().findStaticVarHandle(CTestClass.class,”longField”, long.class);
// or
VarHandle vh = MethodHandles.lookup().findStaticVarHandle(CTestClass.class,”stringField”, Stirng.class);
// and
VarHandle.VarHandleDesc vhd = vh.describeConstable();
then vhd will erroneously describe : VarHandleDesc[static CTestClass.ctestLong:long] or VarHandleDesc[static CTestClass.ctestString:String]
It happens only if CTestClass has both static fields
otherwise if for example the field String ctestString is removed from the CTestClass.class then vh.describeConstable throws the exception:
java.lang.InternalError: Static field not found at offset
at java.base/java.lang.invoke.VarHandles.getStaticFieldFromBaseAndOffset(VarHandles.java:197)
at java.base/java.lang.invoke.VarHandleLongs$FieldStaticReadOnly.describeConstable(VarHandleLongs.java:410)
Thus VarHandle.describeConstable hasn’t been working since fix of
Also any exception thrown by describeConstable should be mentioned in the specification
- relates to
-
JDK-8297757 VarHandles.getStaticFieldFromBaseAndOffset should get the receiver type from VarHandle
-
- Resolved
-