JDK-8207944 : java.lang.ClassFormatError: Extra bytes at the end of class file test" possibly violation of JVMS 4.7.1
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11,12
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2018-07-19
  • Updated: 2018-08-16
  • Resolved: 2018-07-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11 b25Fixed 12Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 7,10 and linux in Jdk/Opendk-11-ea+20

A DESCRIPTION OF THE PROBLEM :
When a none zero length unrecognized attribute is in a class version 55 for ea+20 it has a LinkageError of:
Error: LinkageError occurred while loading main class test
        java.lang.ClassFormatError: Extra bytes at the end of class file test

REGRESSION : Last worked in version 11

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have a class file marked for version 55 with a none zero length unrecognized attribute (See JVMS 4.7.1)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The runtime will ignore the  unrecognized attribute
ACTUAL -
Has a LinkageError:
Error: LinkageError occurred while loading main class test
        java.lang.ClassFormatError: Extra bytes at the end of class file test

CUSTOMER SUBMITTED WORKAROUND :
Compile for JDK 10

FREQUENCY : always



Comments
Looks like this was introduced by the parsing changes for the nestmate related attributes - see JDK-8010319. Thanks for fixing.
30-07-2018

test.class file attached, generated using asmtools.jar jcoder Issue is regression started from 11 ea b20 onwards 11 ea b19 - Pass 11 ea b20 - Fail 11 ea b21 - Fail 12 ea b02 - Fail
23-07-2018

Additional Information: You need to make the class file with asmtools.jar jcoder: test.jcod file is attached
23-07-2018

Please provide standalone test case along with steps to reproduce this issue.
20-07-2018

"Error: LinkageError occurred while loading main class test java.lang.ClassFormatError: Extra bytes at the end of class file test" indicates that file have been truncated to have extra bytes at the end of class file. According to https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-4.html#jvms-4.8 "The class file must not be truncated or have extra bytes at the end." This can occur if there's an incompatibility in Java compiler and Java runtime used. Please check and get back to us.
20-07-2018