Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd class format error #23727

Closed
fwgreen opened this issue Feb 15, 2022 · 9 comments · Fixed by #24106
Closed

Odd class format error #23727

fwgreen opened this issue Feb 15, 2022 · 9 comments · Fixed by #24106
Assignees
Labels
area/kotlin kind/bug Something isn't working
Milestone

Comments

@fwgreen
Copy link

fwgreen commented Feb 15, 2022

Describe the bug

Only The LicensedPracticalNurse class triggers this error at startup while the other classes work fine (removing it fixes the problem). The snippet below is the entire application.

@Path("/api/list")
class ReactiveGreetingResource {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/lpn")
    fun lpn() = LicensedPracticalNurse.listAll()

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/all")
    fun all() = NursingStaffMember.listAll()

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/rn")
    fun rn() = RegisteredNurse.listAll()

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/cna")
    fun cna() = CertifiedNursingAssisant.listAll()
}

enum class JobTitle {
    CNA, RN , LPN
}

@MappedSuperclass
abstract class AbstractStaffMember : PanacheEntity() {
    @Column(name = "staff_id")
    lateinit var staffId: String
    @Column(name = "first_name")
    lateinit var firstName: String
    @Column(name = "last_name")
    lateinit var lastName: String
    @Column(name = "full_name")
    lateinit var fullName: String
    @Enumerated(EnumType.STRING)
    @Column(name = "job_title")
    lateinit var jobTitle: JobTitle
}

@Entity
@Table(name = "LICENSED_PRACTICAL_NURSE")
class LicensedPracticalNurse : AbstractStaffMember() {
    companion object :  PanacheCompanion<LicensedPracticalNurse>
}

@Entity
@Table(name = "REGISTERED_NURSE")
class RegisteredNurse : AbstractStaffMember() {
    companion object :  PanacheCompanion<RegisteredNurse>
}

@Entity
@Table(name = "CERTIFIED_NURSING_ASSISTANT")
class CertifiedNursingAssisant : AbstractStaffMember() {
    companion object :  PanacheCompanion<CertifiedNursingAssisant>
}

Expected behavior

No response

Actual behavior

2022-02-15 09:01:57,346 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
        at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
        at java.base/java.lang.Class.newInstance(Class.java:645)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        ... 6 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
        ... 17 more
Caused by: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion"
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:454)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:414)
        at java.base/java.lang.Class.getDeclaredFields0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
        at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredFieldProperties(JavaXClass.java:84)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:113)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:108)
        at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:258)
        at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:771)
        at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:354)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
        at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:69)
        at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:70)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy_0(Unknown Source)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy(Unknown Source)
        ... 18 more


2022-02-15 09:01:57,376 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
2022-02-15 09:01:57,425 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion"
        at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
        at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:144)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:455)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:66)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion"
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:454)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:414)
        at java.base/java.lang.Class.getDeclaredFields0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
        at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredFieldProperties(JavaXClass.java:84)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:113)
        at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:108)
        at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:258)
        at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:771)
        at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:354)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
        at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:69)
        at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:70)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy_0(Unknown Source)
        at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy(Unknown Source)
        at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
        at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
        at java.base/java.lang.Class.newInstance(Class.java:645)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
        at java.base/java.lang.Thread.run(Thread.java:833)

How to Reproduce?

No response

Output of uname -a or ver

Darwin Kernel Version 21.3.

Output of java -version

openjdk version "17.0.2" 2022-01-18

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4

Additional information

No response

@fwgreen fwgreen added the kind/bug Something isn't working label Feb 15, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 15, 2022

/cc @evanchooly

@geoand
Copy link
Contributor

geoand commented Feb 15, 2022

Seems like a bug in Panache Kotlin

@evanchooly
Copy link
Member

I created a new project from the website and copied these classes in. I can't recreate it. Can you provide a project that recreates this, @fwgreen ?

@fwgreen
Copy link
Author

fwgreen commented Mar 1, 2022

@evanchooly Thanks for taking the time to investigate. Here's a link https://github.com/fwgreen/code-with-quarkus

@evanchooly
Copy link
Member

I've isolated the cause if not the precise why: your model classes are packageless and that trips up quarkus somehow. Try adding a package declaration to your source and see if that resolves your issues. I'll dig in to the why on this end.

@evanchooly
Copy link
Member

the bytecode looks exactly same except for the package related changes, of course. perhaps is a jvm/classloading wrinkle? @dmlloyd ?

@evanchooly evanchooly self-assigned this Mar 2, 2022
@fwgreen
Copy link
Author

fwgreen commented Mar 2, 2022

Putting the models in a package does resolve the problem.

@dmlloyd
Copy link
Member

dmlloyd commented Mar 2, 2022

I think whatever is generating the code is simply generating an invalid signature, or rather one not accepted by the JVM class verifier. The signature is a piece of data used to establish the generic type of the class (as opposed to the descriptor, which is used to unambiguously identify a class or member). The relevant info can be found in §4.7.9 of the JVM specification version 17. I believe the expected signature string in this case would be LLicensedPracticalNurse$Companion; (note the leading L and trailing ;).

@evanchooly
Copy link
Member

ah ha! i think i've found the errant entry (I was looking at the wrong/pretransformation .class files):

    LOCALVARIABLE this LicensedPracticalNurse$Companion L0 L1 0

Others have the appropriate LLicensedPracticalNurse$Companion; formulation. It only appears to affect the local vars section which limits the area to investigate at least.

@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Mar 4, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.4.Final Mar 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kotlin kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants