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

java.lang.AssertionError: typeSig ERROR on generated class property of record

    XMLWordPrintable

Details

    • b16
    • generic
    • generic

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        System:
        Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64

        OS:
        Fedora 34 in WSL

        Java runtime:
        openjdk version "16.0.2" 2021-07-20
        OpenJDK Runtime Environment 21.3 (build 16.0.2+7)
        OpenJDK 64-Bit Server VM 21.3 (build 16.0.2+7, mixed mode, sharing)


        A DESCRIPTION OF THE PROBLEM :
        When a generated class is used as type of a record's property, compilation fails with the following stacktrace:

        java.lang.AssertionError: typeSig ERROR
                at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5168)
                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.putDescriptor(PoolWriter.java:139)
                at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.putDescriptor(PoolWriter.java:146)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeRecordAttribute(ClassWriter.java:852)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1650)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1504)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:757)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1644)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1612)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
                at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
                at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

        It cannot be reproduced by just annotation a random class with @Generated and doesn't happen when replacing the stub with the full generated class and removing code generation altogether

        Hard to tell if it's immutables in the wrong or not, so here goes as per the error message's recommendation

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Given the following interface (using https://immutables.github.io/ ):

        @Immutable
        public interface SomeImmutable {}

        Using the generated concrete class as a record property as such:

        public record SomeRecord(
            ImmutableSomeImmutable someImmutable
        ) { }

        Full reproduction sample at https://github.com/Tristan971/javac-typesig-error

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Successful compilation
        ACTUAL -
        java.lang.AssertionError: typeSig ERROR
                at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5168)
                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.putDescriptor(PoolWriter.java:139)
                at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.putDescriptor(PoolWriter.java:146)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeRecordAttribute(ClassWriter.java:852)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1650)
                at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1504)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:757)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1644)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1612)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
                at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
                at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

        ---------- BEGIN SOURCE ----------
        @Immutable
        public interface SomeImmutable {}

        public record SomeRecord(
            ImmutableSomeImmutable someImmutable
        ) { }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Not using an immutables-generated class as a record property type

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                gli Guoxiong Li
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: