Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297831

typeSig ERROR for generated class field of a record (not a duplicate)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3
    • None
    • 16, 17, 19
    • tools
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Reproducible on all OSs, Java starting from 16 (I didn't test earlier versions)

      A DESCRIPTION OF THE PROBLEM :
      This is not a duplicate of https://bugs.openjdk.org/browse/JDK-8273408
      But it's very similar, that other bug was about having a record field of type that is generated using annotation processor.
      This one is about having a record field of a generic type that is parameterized by a generated type: so instead of just `record Foo(GeneratedClass bar){}`, this time we need the following to reproduce the bug: `record Foo(List<GeneratedClass> bars){}`

      Please see the following repo with a reproducer: https://github.com/nikita2206/jdk-records-generated-class-bug

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Create a maven project
      - add Immutables library as a dependency
      - create a file with the following interface:
      import org.immutables.value.Value;
      @Value.Immutable
      public interface GeneratedClass {
        int foo();
      }

      - create a following file with the Java record:
      import java.util.List;
      public record JavaRecord(int foo, String bar, List<ImmutableGeneratedClass> thisWillFailCompilation) {}

      - Run `mvn install`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This project should build
      ACTUAL -
      Getting the following compilation error:

      java.lang.AssertionError: typeSig ERROR
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5166)
      at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter$SharedSignatureGenerator.assembleSig(PoolWriter.java:298)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5226)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleClassSig(Types.java:5202)
      at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5112)
      at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter$SharedSignatureGenerator.assembleSig(PoolWriter.java:298)
      at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.typeSig(PoolWriter.java:492)
      at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.putSignature(PoolWriter.java:157)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:370)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeRecordAttribute(ClassWriter.java:856)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1651)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1505)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:738)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1617)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1585)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
      at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
      at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
      at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1129)
      at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
      at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:577)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

      ---------- BEGIN SOURCE ----------
      https://github.com/nikita2206/jdk-records-generated-class-bug/commit/00b4c0fb0b6348c534dad1c2af1992c300ab0986
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: