Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassFormatError: Truncated class file #455

Open
micartey opened this issue Jul 1, 2023 · 1 comment
Open

java.lang.ClassFormatError: Truncated class file #455

micartey opened this issue Jul 1, 2023 · 1 comment

Comments

@micartey
Copy link

micartey commented Jul 1, 2023

I am unzipping my jar file and changing a class (adding a static method) and writing the output to that file.
Occasionally (depending on the jar file I am modifying) I get the error specified below:

java.lang.ClassFormatError: Truncated class file
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_362]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_362]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_362]
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) ~[?:1.8.0_362]
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_362]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_362]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_362]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_362]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_362]
	...
  1. Why is this happening?
  2. What do I need to do, to resolve this?
@micartey
Copy link
Author

micartey commented Jul 3, 2023

Using ASM instead solves the issue.
However, I dislike using ASM compared to Javassist...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant