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

How to deal with Findbugs error "Classfile header isn't 0xCAFEBABE in" #706

Closed
stanislr opened this issue Jul 22, 2018 · 7 comments
Closed

Comments

@stanislr
Copy link

Hello,
After upgrade Sonarqube server to version 6.7.4 and its compatible Findbugs plugin v.3.7 we get next error during the Sonar check:
Caused by: edu.umd.cs.findbugs.classfile.InvalidClassFileFormatException: Classfile header isn’t 0xCAFEBABE in ClassName.class

How can we get rid of this error?

@KengoTODA
Copy link
Member

Could you share your .class file?

@stanislr
Copy link
Author

Attaching
I have changed extension from .class to .zip as class files can not be uploaded here
UpdateASCFiles.zip

@KengoTODA
Copy link
Member

I've checked this binary file. It seems that it has EFBFBD header, that is explained at https://blog.gdssecurity.com/labs/2015/2/18/when-efbfbd-and-friends-come-knocking-observations-of-byte-a.html

So I guess that you generated this .class file with some tools that isn't javac? Or edited by some editor? Please make sure that .class file is really generated by javac.

@stanislr
Copy link
Author

stanislr commented Jul 24, 2018

Thanks for checking KengoToda.
Not sure how link you sent is related to the issue as in link it is explained about key generation and not file header type.
We tried to use Findbugs filters to skip this specific class during Sonar analysis but nothing worked.
Is there any other way to skip this file in analysis?
Also we would expect that Findbugs will not fail the whole analysis but only prints warning/info about file that failed in check and will continue to run.
Is any such enhancement may be done?

@ThrawnCA
Copy link
Contributor

ThrawnCA commented Jul 24, 2018

The relevance of the link is, if something created this class file by generating a sequence of bytes and then converting them to a String, before writing them to a file, then that would explain the EFBFBD sequence.

In any case, without the CAFEBABE header, it's not a valid class file.

@KengoTODA
Copy link
Member

Is any such enhancement may be done?

SpotBugs has no full-time contributor nor supporter. So if you have suggestion, please raise PR by own... it should be easiest/fastest way to make it real.

@KengoTODA
Copy link
Member

I'll close this stale issue, please feel free to reopen.

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

3 participants