Skip to content

Java 16 Records breaking build-frontend #10870

Closed

Description

@dcmlx

I am using Java 16 Records and there seems to be an issue doing a build with production mode enabled.

POM Versions...
<java.version>16</java.version>
<vaadin.version>19.0.6</vaadin.version>

Run this on command line...
mvn -Pproduction package

When the build-frontend runs...
com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend

I get this error...
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend (default) on project artemis: Execution default of goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend failed: Record requires ASM8 -> [Help 1]

Looks like the bytebuddy code generator is not working with Java 16 records?

Activity

  1. transferred this issue fromvaadin/maven-pluginon May 3, 2021
  2. miguelatvaadin commented on May 6, 2021

    @miguelatvaadin
    Contributor

    Hi @dcmlx ,

    thanks for reporting this.

    However, I'm not able to reproduce the issue. Could you please provide more details (e.g. jdk used)?

    Thanks and best regards,

  3. dcmlx commented on May 6, 2021

    @dcmlx
    Author

    Hi @miguelatvaadin

    ** jdk version...

    openjdk version "16" 2021-03-16
    OpenJDK Runtime Environment Corretto-16.0.0.36.1 (build 16+36)
    OpenJDK 64-Bit Server VM Corretto-16.0.0.36.1 (build 16+36, mixed mode, sharing)

    ** Try adding this Record to your code to reproduce...

    @JsonIgnoreProperties(value = "password")
    public record User(Integer accountId,
    String email,
    String firstName,
    String lastName,
    Role role,
    UserStatus accountStatus,
    LocalDate createdOn) {
    }

    ** This is the output from maven...

    [INFO] --- vaadin-maven-plugin:19.0.6:build-frontend (default) @ artemis ---
    [INFO] Scanning classes to find frontend configurations and dependencies...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 14.400 s
    [INFO] Finished at: 2021-05-06T19:28:19+01:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend (default) on project artemis: Execution default of goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend failed: Record requires ASM8 -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend (default) on project artemis: Execution default of goal com.vaadin:vaadin-maven-plugin:19.0.6:build-frontend failed: Record requires ASM8
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)

    ** Now if I swap out the Record above with a regular java class, vaadin-maven-plugin:19.0.6:build-frontend works without any issues.

    thanks!

  4. dcmlx commented on May 6, 2021

    @dcmlx
    Author

    Looks like the problem happens when you create an instance of the record inside a vaadin view. To be clear, the issue happens at compile time during the build-frontend maven goal.

    @route(value = "company", layout = MainView.class)
    public class CompanySettingsView extends Div {

    public CompanySettingsView(UserService userService ) {
        var u = new Simple(...);  <--comment out this record creation and the ASM8 problem goes away
    
  5. dcmlx commented on May 7, 2021

    @dcmlx
    Author

    So it appears vaadin FrontendDependencies class calls bytebuddy. And when byte buddy scans an instance of a Record it fails. Looks like the Opcodes version is set to Opcodes.ASM7 and not ASM8. Not sure how this is set internally but looks like its the source of the problem.

    Caused by: java.lang.UnsupportedOperationException: Record requires ASM8
    at net.bytebuddy.jar.asm.ClassVisitor.visitRecordComponent (ClassVisitor.java:305)
    at net.bytebuddy.jar.asm.ClassReader.readRecordComponent (ClassReader.java:930)
    at net.bytebuddy.jar.asm.ClassReader.accept (ClassReader.java:708)
    at net.bytebuddy.jar.asm.ClassReader.accept (ClassReader.java:401)
    at com.vaadin.flow.server.frontend.scanner.FrontendDependencies.visitClass (FrontendDependencies.java:556)
    at com.vaadin.flow.server.frontend.scanner.FrontendDependencies.visitClass (FrontendDependencies.java:568)

    image

  6. miguelatvaadin commented on May 7, 2021

    @miguelatvaadin
    Contributor

    Hi @dcmlx ,

    yes. I was looking at the same thing. The maven plugin depends on the 1.10.9 version of bytebuddy, but record support and ASM8 were added on version 1.10.10.

    I'm looking for a workaround, before qualifying this issue.

  7. miguelatvaadin commented on May 7, 2021

    @miguelatvaadin
    Contributor

    well, besides the bytebuddy version, ASM7 is hardcoded in FrontendMethodVisitor.java:69

        private final class FrontendMethodVisitor extends MethodVisitor {
            public FrontendMethodVisitor() {
                super(Opcodes.ASM7);
            }
  8. miguelatvaadin commented on May 7, 2021

    @miguelatvaadin
    Contributor

    ...and in some other visitor classes, in the flow server project.

    I will qualify this issue so it can be addressed.

    Thanks @dcmlx

  9. self-assigned this
    on May 14, 2021
  10. added a commit that references this issue on May 14, 2021
    f5d6ebc
  11. 6 remaining items

  12. added 3 commits that reference this issue on May 14, 2021
    fd5c95d
    d93af5d
    cacdf21
  13. added a commit that references this issue on May 17, 2021
    d3dec92
  14. added a commit that references this issue on May 18, 2021
    24740f5
  15. vaadin-bot commented on May 19, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 19.0.8. For prerelease versions, it will be included in its final version.

  16. vaadin-bot commented on May 19, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 20.0.0.beta2. For prerelease versions, it will be included in its final version.

  17. vaadin-bot commented on May 20, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 21.0.0.alpha2. For prerelease versions, it will be included in its final version.

  18. vaadin-bot commented on Jun 7, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 14.6.2. For prerelease versions, it will be included in its final version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions