-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
P4
-
Affects Version/s: 8, 9
-
Component/s: core-libs
-
generic
-
generic
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
Some compilers and obfuscators often break generic type signatures. This can result in a NullPointerException with the reflection API. For example, using:
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core_2.11</artifactId>
<version>2.4.11</version>
</dependency>
running this code:
Class<?> type = Class.forName("akka.stream.scaladsl.Sink$$anon$1");
Field field = type.getDeclaredField("akka$stream$scaladsl$Sink$$anon$$in");
Type fieldType = field.getGenericType();
System.out.println(fieldType);
throws a NullPointerException. This is due to the reflection API not being able to resolve a type variable that is not declared in the type's scope. This results in the variable being null. Reading the parameter types returns an array containing null, too.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the above code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A more meaningful exception or even the possibility to create a toString representation.
ACTUAL -
A NullPointerException.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See the above description.
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
Some compilers and obfuscators often break generic type signatures. This can result in a NullPointerException with the reflection API. For example, using:
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core_2.11</artifactId>
<version>2.4.11</version>
</dependency>
running this code:
Class<?> type = Class.forName("akka.stream.scaladsl.Sink$$anon$1");
Field field = type.getDeclaredField("akka$stream$scaladsl$Sink$$anon$$in");
Type fieldType = field.getGenericType();
System.out.println(fieldType);
throws a NullPointerException. This is due to the reflection API not being able to resolve a type variable that is not declared in the type's scope. This results in the variable being null. Reading the parameter types returns an array containing null, too.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the above code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A more meaningful exception or even the possibility to create a toString representation.
ACTUAL -
A NullPointerException.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See the above description.
---------- END SOURCE ----------
- caused by
-
JDK-8337302 Undefined type variable results in null
-
- Closed
-
- duplicates
-
JDK-8337302 Undefined type variable results in null
-
- Closed
-