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

IncorrectInternalClassUse throws a ClassFormatException after upgrading to Spotbugs 6.0.3 #456

Closed
donalmurtagh opened this issue Dec 15, 2023 · 5 comments

Comments

@donalmurtagh
Copy link

donalmurtagh commented Dec 15, 2023

I upgraded the Spotbugs Gradle plugin from 6.0.2 to 6.0.3. After the upgrade I ran the checks, and I now get a lot of these exceptions (one for every class analysed, I think)

The following errors occurred during analysis:
  Exception analyzing com.example.MyClass using detector com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse
    org.apache.bcel.classfile.ClassFormatException: Invalid constant pool reference using index: 0. Constant pool size is: 44
      At org.apache.bcel.classfile.ConstantPool.getConstant(ConstantPool.java:305)
      At org.apache.bcel.classfile.ConstantPool.getConstant(ConstantPool.java:257)
      At com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse.visitClassContext(IncorrectInternalClassUse.java:85)
      At edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
      At edu.umd.cs.findbugs.FindBugs2.lambda$analyzeApplication$1(FindBugs2.java:1108)
      At java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      At edu.umd.cs.findbugs.CurrentThreadExecutorService.execute(CurrentThreadExecutorService.java:86)
      At java.base/java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:247)
      At edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1118)
      At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:309)
      At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:395)
      At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1231)

I'm using v7.6.3 of sb-contrib.

@donalmurtagh donalmurtagh changed the title IncorrectInternalClassUse throws a ClassFormatException after upgrading from 6.0.2 to 6.0.4 IncorrectInternalClassUse throws a ClassFormatException after upgrading to Spotbugs 6.0.4 Dec 15, 2023
@mebigfatguy
Copy link
Owner

mebigfatguy commented Dec 15, 2023

is it possible to get the .classfile for the problematic class? What version of java was the target class compiled in?

@donalmurtagh
Copy link
Author

donalmurtagh commented Dec 17, 2023

is it possible to get the .classfile for the problematic class? What version of java was the target class compiled in?

@mebigfatguy When you say "problematic class", do you mean the class being analyzed, i.e. com.example.MyClass in the example above? My app uses JDK21, so that's what all of the analyzed classes were compiled with.

@mebigfatguy
Copy link
Owner

yes com.example.MyClass, probably related to jdk21

@donalmurtagh donalmurtagh changed the title IncorrectInternalClassUse throws a ClassFormatException after upgrading to Spotbugs 6.0.4 IncorrectInternalClassUse throws a ClassFormatException after upgrading to Spotbugs 6.0.3 Dec 18, 2023
@donalmurtagh
Copy link
Author

donalmurtagh commented Dec 18, 2023

@mebigfatguy I added the following trivial class to my project

package com.example;

public class MyClass {
}

I ran Spotbugs and confirmed that the error occurs for this class (it seems to occur for every analysed class).

  Exception analyzing com.example.MyClass using detector com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse
    org.apache.bcel.classfile.ClassFormatException: Invalid constant pool reference using index: 0. Constant pool size is: 16
      At org.apache.bcel.classfile.ConstantPool.getConstant(ConstantPool.java:305)
      At org.apache.bcel.classfile.ConstantPool.getConstant(ConstantPool.java:257)
      At com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse.visitClassContext(IncorrectInternalClassUse.java:85)
      At edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)

I've attached MyClass.class file to this comment. I had to add it as a .zip archive because GitHub doesn't allow .class file attachments.

MyClass.class.zip

@mebigfatguy
Copy link
Owner

targetted for 7.6.4

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

No branches or pull requests

2 participants