Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-243

Java 8 type-use annotation breaks relocation

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.3
    • Fix Version/s: None
    • Labels:

      Description

      When relocation tries to examine a class with type-use annotation for remapping it fails in org.objectweb.asm.ClassReader.readLabel() (in some cases).

      This code can be used to reproduce the issue:

      import org.jetbrains.annotations.Nullable;
      
      interface Foo<V> { void foo(V x); }
      
      class FooImpl implements Foo<Iterable<Object>> {
          public void foo(Iterable<Object> result) {
              if ("".equals(null)) {
                  @Nullable Object o = null;
                  o = null; // without a statement here errs at offset 65535 instead of 11
              }
          }
      }
      

      Running mvn package (with <relocation> in shade configuration) yields:

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (default) on project asm-bug: Error creating shaded jar: Error in ASM processing class FooImpl.class: 11 -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (default) on project asm-bug: Error creating shaded jar: Error in ASM processing class FooImpl.class
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
      	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: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: Error in ASM processing class FooImpl.class
      	at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:540)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
      	... 20 more
      Caused by: org.apache.maven.plugin.MojoExecutionException: Error in ASM processing class FooImpl.class
      	at org.apache.maven.plugins.shade.DefaultShader.addRemappedClass(DefaultShader.java:450)
      	at org.apache.maven.plugins.shade.DefaultShader.shadeSingleJar(DefaultShader.java:219)
      	at org.apache.maven.plugins.shade.DefaultShader.shadeJars(DefaultShader.java:179)
      	at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:104)
      	at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:454)
      	... 22 more
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 11
      	at org.objectweb.asm.ClassReader.readLabel(Unknown Source)
      	at org.objectweb.asm.ClassReader.a(Unknown Source)
      	at org.objectweb.asm.ClassReader.a(Unknown Source)
      	at org.objectweb.asm.ClassReader.b(Unknown Source)
      	at org.objectweb.asm.ClassReader.accept(Unknown Source)
      	at org.objectweb.asm.ClassReader.accept(Unknown Source)
      	at org.apache.maven.plugins.shade.DefaultShader.addRemappedClass(DefaultShader.java:446)
      	... 26 more
      

      Related ASM issue: #317778.

        Attachments

        1. mshade-243.zip
          2 kB
          Yegor Borovikov

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yborovikov Yegor Borovikov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: