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

JEP 330: may need to recompile in case of class file version mismatch

    XMLWordPrintable

Details

    • Backport
    • Resolution: Withdrawn
    • P3
    • 11-pool-oracle
    • 11
    • tools
    • None

    Description

      I felt bad about never having even tried out the single file java feature
      JEP 330: Launch Single-File Source-Code Programs
      https://openjdk.java.net/jeps/330

      (even though I've maintained my own such program for many years)
      but my very first try failed:

      $ java Main.java
      Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 55.0
      at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)

      The problem is that I had already compiled and run this program with jdk13 and (unlike my own script) jdk11 was unwilling to unconditionally recompile the source file. One of the reasons why my script does unconditionally recompile is to solve this exact problem. Another reason I unconditionally recompile is that I am usually interested in any javac warnings. A middle ground would be to recompile iff there is a class file version mismatch.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: