Creating TypeInfo with class defined in method scope throws GenericSignatureFormatError
See original GitHub issueCreating a TypeInfo
like this:
@Test
fun `type info with class defined in method scope`() {
class SomeClass
typeInfo<SomeClass>()
}
Causes a GenericSignatureFormatError
with the following stack trace:
java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected '<' or ';' but got
Remaining input: info with class defined in method scope$SomeClass;>;
at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124)
at sun.reflect.generics.parser.SignatureParser.parsePackageNameAndSimpleClassTypeSignature(SignatureParser.java:348)
at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignature(SignatureParser.java:310)
at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:289)
at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:283)
at sun.reflect.generics.parser.SignatureParser.parseTypeArgument(SignatureParser.java:436)
at sun.reflect.generics.parser.SignatureParser.parseTypeArguments(SignatureParser.java:396)
at sun.reflect.generics.parser.SignatureParser.parsePackageNameAndSimpleClassTypeSignature(SignatureParser.java:346)
at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignature(SignatureParser.java:310)
at sun.reflect.generics.parser.SignatureParser.parseClassSignature(SignatureParser.java:213)
at sun.reflect.generics.parser.SignatureParser.parseClassSig(SignatureParser.java:156)
at sun.reflect.generics.repository.ClassRepository.parse(ClassRepository.java:57)
at sun.reflect.generics.repository.ClassRepository.parse(ClassRepository.java:41)
at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:74)
at sun.reflect.generics.repository.GenericDeclRepository.<init>(GenericDeclRepository.java:49)
at sun.reflect.generics.repository.ClassRepository.<init>(ClassRepository.java:53)
at sun.reflect.generics.repository.ClassRepository.make(ClassRepository.java:70)
at java.lang.Class.getGenericInfo(Class.java:2548)
at java.lang.Class.getGenericSuperclass(Class.java:765)
at de.nielsfalk.playground.ktor.swagger.ModelExtractionTest.type info with class defined in method scope(ModelExtractionTest.kt:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Kotlin IntelliJ Plugin version: 1.2.50-release-IJ2018.1-1
Same issue exists when running the test through Gradle which is using Kotlin version 1.2.50
.
In the typeInfo
method it seems to be failing here:
inline fun <reified T> typeInfo(): TypeInfo {
val base = object : TypeBase<T>() {}
val superType = base::class.java.genericSuperclass!! // <== This line here.
val reifiedType = (superType as ParameterizedType).actualTypeArguments.first()!!
return TypeInfo(T::class, reifiedType)
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
New src/java.base/share/classes/java/lang/Class.java
Only the Java Virtual Machine creates Class objects. ... and 393 * the given name is a class defined in a different module,...
Read more >Access class defined in method in Java
I am currently developing tool that works with java code. So i need to know if tool automaticaly change location of inner class...
Read more >ClassLoader (Java Platform SE 8 )
The method defineClass converts an array of bytes into an instance of class Class. Instances of this newly defined class can be created...
Read more >Class (Java Platform SE 8 )
Returns an array containing Method objects reflecting all the declared methods of the class or interface represented by this Class object, including public, ......
Read more >Class.java - Android Code Search
@throws java.lang.reflect.GenericSignatureFormatError if the generic. * class signature does not conform to the format specified in.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Look’s like an interop issue in the compiler. I’m investigating now.
Please consider avoiding spaces in names with
TypeInfo
usages.motivation: https://youtrack.jetbrains.com/issue/KT-25337