-
Bug
-
Resolution: Unresolved
-
P3
-
8u40, 9, 20
-
Fix Understood
Try running the demo program below with jdk8 and jdk9:
In jdk8 we get the correct output:
receiver type=sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl@6d06d69c
receiver type=sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl@7852e922
In jdk9 we get:
receiver type=null
receiver type=sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl@5f375618
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.lang.reflect.Constructor;
public class ReceiverType {
public static void main(String[] args) throws Throwable {
new ReceiverType().instanceMain();
}
class Member {
Member(ReceiverType ReceiverType.this) {}
}
public void instanceMain() throws Throwable {
class Local {
Local(ReceiverType ReceiverType.this) {}
}
printConstructor(Local.class);
printConstructor(Member.class);
}
static void printConstructor(Class<?> klazz) {
Constructor<?>[] constructors = klazz.getDeclaredConstructors();
if (constructors.length != 1) throw new AssertionError();
System.out.printf("receiver type=%s%n",
constructors[0].getAnnotatedReceiverType());
}
}
- relates to
-
JDK-8162500 Receiver annotations of inner classes of local classes not found at runtime
-
- In Progress
-
-
JDK-8292275 javac does not emit SYNTHETIC and MANDATED flags for parameters by default
-
- Resolved
-
-
JDK-8029042 Receiver parameter not supported on local class constructor
-
- Closed
-
-
JDK-8044629 (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
-
- Closed
-
-
JDK-8179109 8.4.1: Error for receiver parameter of an inner class in a static context
-
- Closed
-