-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
The 'FIXME' in this method in java/lang/invoke/MemberName.java needs fixing:
/** Create a name for the given reflected constructor. The
resulting name will be in a resolved state. */
@SuppressWarnings("LeakingThisInConstructor")
public MemberName(Constructor<?> ctor) {
Objects.requireNonNull(ctor);
// fill in vmtarget, vmindex while we have ctor in hand:
MethodHandleNatives.init(this, ctor);
assert(isResolved() && this.clazz != null);
this.name = CONSTRUCTOR_NAME;
if (this.type == null) {
Class<?> rtype = void.class;
if (isStatic()) { // a static init factory, not a true constructor
rtype = getDeclaringClass();
// FIXME: If it's a hidden class, this sig won't work.
}
this.type = new Object[] { rtype, ctor.getParameterTypes() };
}
}
The problem is that static init factory methods normally return the type of their declaring inline class. But, if the declaring class is a VM unsafe anonymous class then the return type is java.lang.Object.
But, this code doesn't check if the declaring class is a VM unsafe anonymous class and it is unclear how it could do so.
/** Create a name for the given reflected constructor. The
resulting name will be in a resolved state. */
@SuppressWarnings("LeakingThisInConstructor")
public MemberName(Constructor<?> ctor) {
Objects.requireNonNull(ctor);
// fill in vmtarget, vmindex while we have ctor in hand:
MethodHandleNatives.init(this, ctor);
assert(isResolved() && this.clazz != null);
this.name = CONSTRUCTOR_NAME;
if (this.type == null) {
Class<?> rtype = void.class;
if (isStatic()) { // a static init factory, not a true constructor
rtype = getDeclaringClass();
// FIXME: If it's a hidden class, this sig won't work.
}
this.type = new Object[] { rtype, ctor.getParameterTypes() };
}
}
The problem is that static init factory methods normally return the type of their declaring inline class. But, if the declaring class is a VM unsafe anonymous class then the return type is java.lang.Object.
But, this code doesn't check if the declaring class is a VM unsafe anonymous class and it is unclear how it could do so.
- is blocked by
-
JDK-8249071 Remove restrictions on <init> factory methods
- Closed
- relates to
-
JDK-8222787 [lworld] JVM should be enhanced to work with static <init> factory methods for inline types
- Resolved
-
JDK-8247795 [lworld] Fix VM support of factory methods for inline hidden and UAC classes
- Resolved
-
JDK-8205668 [lworld] Make the lambda proxy classes to be inline hidden classes
- Open
(1 links to)