Open glassfishrobot opened 7 years ago
@stefanocke Commented For a possible explanation of this error, see also here:
https://github.com/japkit/japkit/issues/23#issuecomment-366711150
Summary: It is an issue with Type Annotations in javac annotation processing in general.
GlassFish uses HK2. HK2 uses bean validation. As GlassFish starts supporting Java EE 8 and Bean Validation 2.0 API, HK2's usage of bean validation should be compatible with the bean validation API & implementation provided in GlassFish.
1) First requirement is to relax the OSGi package constraint in Hk2 for BV APIs and Hibernate Validator Implementation. We have worked with Mason and Mason has merged the changes in master of hk2. https://github.com/javaee/hk2/pull/361
2) When GlassFish uses BV 2.0 (javax.validation.constraint.Min/Max etc.,) APIs, Hk2's config bean generator module results in compilation failure listed below.
We need a fix for this so as to support bean validation 2.0 in GlassFish.
STEPS TO REPRODUCE: Use the following pull request in GlassFIsh and do a full build to see the compilation error. https://github.com/javaee/glassfish/pull/21962
COMPILATION ERROR:
INFO] --- config-generator:2.5.0-b33:generate-injectors (default-generate-injectors) @ grizzly-config --- [INFO] /scratch/jaramu/space/jagadish/workspaces/glassfish5-git-hub/glassfish/nucleus/grizzly/config/target/generated-sources/hk2-config-generator/src/main/java [ERROR] Exception from hk2-config-generator[0]=java.lang.ClassCastException: com.sun.tools.javac.code.Type$ClassType cannot be cast to com.sun.tools.javac.code.Type$ArrayType java.lang.RuntimeException: java.lang.ClassCastException: com.sun.tools.javac.code.Type$ClassType cannot be cast to com.sun.tools.javac.code.Type$ArrayType at com.sun.tools.javac.main.Main.compile(Main.java:553) at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129) at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138) at org.jvnet.hk2.config.generator.maven.AbstractConfigGeneratorMojo.internalExecute(AbstractConfigGeneratorMojo.java:157) at org.jvnet.hk2.config.generator.maven.AbstractConfigGeneratorMojo.execute(AbstractConfigGeneratorMojo.java:175) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) 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:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 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.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) Caused by: java.lang.ClassCastException: com.sun.tools.javac.code.Type$ClassType cannot be cast to com.sun.tools.javac.code.Type$ArrayType at com.sun.tools.javac.code.Type$AnnotatedType.getComponentType(Type.java:2018) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$MethodGenerator$ArrayPacker.itemType(ConfigInjectorGenerator.java:616) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$MethodGenerator$ArrayPacker.<init>(ConfigInjectorGenerator.java:611) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$MethodGenerator.createPacker(ConfigInjectorGenerator.java:566) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$MethodGenerator.<init>(ConfigInjectorGenerator.java:454) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$AttributeMethodGenerator.<init>(ConfigInjectorGenerator.java:847) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator$AttributeMethodGenerator.<init>(ConfigInjectorGenerator.java:843) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator.generate(ConfigInjectorGenerator.java:382) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$ClassGenerator.generate(ConfigInjectorGenerator.java:359) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$GeneratorVisitor.visitType(ConfigInjectorGenerator.java:185) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator$GeneratorVisitor.visitType(ConfigInjectorGenerator.java:172) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1150) at org.jvnet.hk2.config.generator.ConfigInjectorGenerator.process(ConfigInjectorGenerator.java:160) 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) ... 26 more