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

Cannot compile non-module classfile with Java 11.

XMLWordPrintable

    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "11" 2018-09-25
      OpenJDK Runtime Environment 18.9 (build 11+28)
      OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

      Debian GNU/Linux 9 (stretch) 64-bit

      AMD® Fx(tm)-8320 eight-core processor × 8
      GeForce GTX 950/PCIe/SSE2

      A DESCRIPTION OF THE PROBLEM :
      javac fails to compile a simple project that includes a single jar on the classpath.

      ```
      ./src/main/java/dummy/App.java:1: error: cannot access dummy
      package dummy;
      ^
        zip END header not found
      ```

      When you remove the jar from the classpath, or add a module-info.java file to the project, it compiles without issue.

      The jar itself is jsr305 from google, but it's not the only jar that's had this reaction.
      I've tested it with apache-tika.
      I've built a quickstart that emits this error everytime.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I've made a quickstart, and if I can attach it in some way, it might speed up the process.

      But the steps themselves are simple enough.

      Create a java file, fill it out with a simple hello world (I've added the source code for the file below).

      For me, particularly, I've be able to reproduce it 100% with jsr305-1.3.9.
      Grab that from maven central or the repo of your choice.
      The one I have is exactly 33,167 bytes.
      Don't know if there's different sizes in different repos...
      There shouldn't be, but just in case. :D

      Add all of that into a typical java project, and then try to compile.

      javac -cp ./libs/jsr305-1.3.9.jar -d ./target/classes -sourcepath ./src/main/java ./src/main/java/dummy/App.java

      You can add a release flag, but I tested 11 and 8, both had the same effect.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The classfile compiles without any errors.
      ACTUAL -
      Classfile fails to compile and javac spits out:

      ```
      ./src/main/java/dummy/App.java:1: error: cannot access dummy
      package dummy;
      ^
        zip END header not found
      ```

      ---------- BEGIN SOURCE ----------
      App.java:
      ```
      package dummy;

      public class App
      {
          public static void main( String[] args )
          {
              System.out.println( "Hello World!" );
          }
      }
      ```
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Removing the library from the classpath or add a module-info.java does solve the issue.
      The probably with that is, of course, if it's a big application, you have to make the leap to Java 11 and the "new" module system.

      FREQUENCY : always


            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: