mvysny / karibu-dsl

Kotlin Vaadin extensions and DSL
http://www.vaadinonkotlin.eu
MIT License
126 stars 16 forks source link

Vaadin 10 fails with Invisible parameter type of kotlin.jvm.internal.DefaultConstructorMarker #3

Open mvysny opened 7 years ago

mvysny commented 7 years ago

When I launch the Beverage Buddy Vaadin 10 example and hit "Edit" button on the Reviews list, I'll get the following exception in the console:

01-Nov-2017 08:46:04.165 SEVERE [http-nio-8080-exec-4] com.vaadin.server.DefaultErrorHandler.error 
 java.lang.IllegalStateException: Invisible parameter type of kotlin.jvm.internal.DefaultConstructorMarker arg7 for public com.vaadin.starter.beveragebuddy.backend.Review$(java.lang.Long,int,java.lang.String,java.time.LocalDate,com.vaadin.starter.beveragebuddy.backend.Category,int,int,kotlin.jvm.internal.DefaultConstructorMarker)
    at net.bytebuddy.dynamic.scaffold.InstrumentedType$Default.validated(InstrumentedType.java:925)
    at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:465)
    at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:162)
    at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:155)
    at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2639)
    at com.vaadin.flow.model.TemplateModelProxyHandler.createProxyConstructor(TemplateModelProxyHandler.java:246)
    at com.vaadin.flow.model.TemplateModelProxyHandler.createClassConstructor(TemplateModelProxyHandler.java:222)
    at com.vaadin.flow.model.TemplateModelProxyHandler.createProxyConstructor(TemplateModelProxyHandler.java:204)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at com.vaadin.flow.util.ReflectionCache.get(ReflectionCache.java:69)
    at com.vaadin.flow.model.TemplateModelProxyHandler.createModelProxy(TemplateModelProxyHandler.java:193)
    at com.vaadin.flow.model.BeanModelType.modelToApplication(BeanModelType.java:314)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.getTemplateItem(PublishedServerEventHandlerRpcHandler.java:257)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArg(PublishedServerEventHandlerRpcHandler.java:224)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArgs(PublishedServerEventHandlerRpcHandler.java:174)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:128)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:112)
    at com.vaadin.server.communication.rpc.PublishedServerEventHandlerRpcHandler.handleNode(PublishedServerEventHandlerRpcHandler.java:92)
    at com.vaadin.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:50)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:397)
    at com.vaadin.server.communication.ServerRpcHandler.lambda$handleInvocations$0(ServerRpcHandler.java:387)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:387)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:304)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:86)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1480)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:298)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
mvysny commented 7 years ago

Reported as a bug to the ByteBuddy library: https://github.com/raphw/byte-buddy/issues/350 Most probably caused by the bug in the Kotlin compiler: https://youtrack.jetbrains.com/issue/KT-20869 Unfortunately there are no known workarounds as of now.

mvysny commented 7 years ago

The only workaround I could found is that the class must have a public zero-arg constructor, and all fields must then be listed outside of any constructor.

WakeRealityDev commented 6 years ago

"The only workaround I could found is that the class must have a public zero-arg constructor, and all fields must then be listed outside of any constructor"

If it's any consolation, Google seems to run into similar issues with plain Java and Android framework, so at least you have company. Example: https://stackoverflow.com/questions/44194579/android-viewmodel-has-no-zero-argument-constructor

mvysny commented 6 years ago

Lots of frameworks tend to require zero-arg constructor - that's completely OK. However, this bug is something else - it's a bug in Kotlin compiler which produces illegal bytecode. Please read more here: https://github.com/raphw/byte-buddy/issues/350

mvysny commented 6 years ago

If you'd like this bug to be fixed, please upvote https://youtrack.jetbrains.com/issue/KT-20869 by starring it.