vert-x3 / vertx-service-proxy

EventBus Proxy generation
Apache License 2.0
67 stars 58 forks source link

@ProxyGen buildable on 3.0.0 fails on 3.1.0-SNAPSHOT with 'cannot be cast to io.vertx.codegen.TypeInfo$Class$Api' #22

Closed msavy closed 9 years ago

msavy commented 9 years ago

An interface that looks (simplified) like this, and compiled fine with vertx 3.0.0:

IngestorToPolicyService is labelled with @ProxyGen and @VertxGen.

@ProxyGen
public interface InitializeIngestorService {

    void createIngestor(String uuid, Handler<AsyncResult<IngestorToPolicyService>> resultHandler);

    static InitializeIngestorService create(Vertx vertx) {
        return new InitializeIngestorServiceImpl(vertx);
    }

    static InitializeIngestorService createProxy(Vertx vertx, String address) {
        return ProxyHelper.createProxy(InitializeIngestorService.class, vertx, address);
    }
}

The error is extremely cryptic to me:

SEVERE: Could not generate element for io.vertx.apiman.gateway.platforms.vertx2.services.InitializeIngestorService: io.vertx.codegen.TypeInfo$Class cannot be cast to io.vertx.codegen.TypeInfo$Class$Api
java.lang.ClassCastException: io.vertx.codegen.TypeInfo$Class cannot be cast to io.vertx.codegen.TypeInfo$Class$Api
    at io.vertx.codegen.ClassModel.getTypeParams(ClassModel.java:215)
    at io.vertx.codegen.ClassModel.getVars(ClassModel.java:807)
    at io.vertx.codegen.CodeGenProcessor.lambda$process$66(CodeGenProcessor.java:148)
    at io.vertx.codegen.CodeGenProcessor$$Lambda$23/895697353.accept(Unknown Source)
    at java.util.stream.StreamSpliterators$WrappingSpliterator$$Lambda$24/678054994.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1683)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
    at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at io.vertx.codegen.CodeGenProcessor.process(CodeGenProcessor.java:137)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    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:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
cescoffier commented 9 years ago

Julien had made lots of improvements last week on codegen. So it may be a side effect. Gonna have a look.

On 1 août 2015, at 20:21, Marc Savy notifications@github.com wrote:

An interface that looks (simplified) like this, and compiled fine with vertx 3.0.0:

IngestorToPolicyService is labelled with @ProxyGen and @VertxGen.

@ProxyGen public interface InitializeIngestorService {

void createIngestor(String uuid,

Handler<AsyncResult> resultHandler);

static InitializeIngestorService create(Vertx vertx) {
    return new InitializeIngestorServiceImpl(vertx);
}

static InitializeIngestorService createProxy(Vertx vertx, String address) {
    return ProxyHelper.createProxy(InitializeIngestorService.class,

vertx, address); } }

The error is extremely cryptic to me:

SEVERE: Could not generate element for io.vertx.apiman.gateway.platforms.vertx2.services.InitializeIngestorService: io.vertx.codegen.TypeInfo$Class cannot be cast to io.vertx.codegen.TypeInfo$Class$Api java.lang.ClassCastException: io.vertx.codegen.TypeInfo$Class cannot be cast to io.vertx.codegen.TypeInfo$Class$Api at io.vertx.codegen.ClassModel.getTypeParams(ClassModel.java:215) at io.vertx.codegen.ClassModel.getVars(ClassModel.java:807) at io.vertx.codegen.CodeGenProcessor.lambda$process$66(CodeGenProcessor.java:148) at io.vertx.codegen.CodeGenProcessor$$Lambda$23/895697353.accept(Unknown Source) at java.util.stream.StreamSpliterators$WrappingSpliterator$$Lambda$24/678054994.accept(Unknown Source) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1683) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743) at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743) at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743) at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) at io.vertx.codegen.CodeGenProcessor.process(CodeGenProcessor.java:137) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129) at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138) at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785) at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) 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:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

— Reply to this email directly or view it on GitHub https://github.com/vert-x3/vertx-service-proxy/issues/22.

vietj commented 9 years ago

Hi, this is due to a unnecessary cast that casts the type to a TypeInfo.Class.Api whereas the getParams() method is available on TypeInfo.Class. I removed this cast https://github.com/vert-x3/vertx-codegen/commit/f3ee05a34a501e7531e2f395ade326007c9d21cb and now it should be fine.

msavy commented 9 years ago

@cescoffier @vietj thanks for the fix, gents.

cescoffier commented 9 years ago

Closing the issue as it was fixed in codegen. Please reopen if the issue is not gone.