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

Prevent AOBE on empty, bad class files. #5137

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

lkishalmi
Copy link
Contributor

Today NetBeans greeted me with the following Exception:

java.lang.ArrayIndexOutOfBoundsException: Index 6 out of bounds for length 0
	at org.netbeans.lib.nbjavac.services.NBClassReader.readClassFile(NBClassReader.java:91)
	at com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:374)
	at com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:303)
	at org.netbeans.lib.nbjavac.services.NBClassFinder.lambda$getCompleter$1(NBClassFinder.java:95)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:682)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1410)
	at com.sun.tools.javac.code.ClassFinder.loadClass(ClassFinder.java:447)
...

This one is a trivial fix, not to try to get the class version if the class file is actually empty. Could happen in some cases (e.g. a laptop lose power while sleeping for too long.)

@lkishalmi lkishalmi added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Dec 22, 2022
@lkishalmi lkishalmi added this to the NB17 milestone Dec 22, 2022
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. This is going to throw BadClassFile for empty classes which more correct than index out of bounds.

@lkishalmi lkishalmi merged commit 30a8cef into apache:master Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants