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

"Can't get stack offset 0 from [] @ 0" error reported by DumbMethods$NullMethodsSubDetector #2640

Closed
iloveeclipse opened this issue Oct 16, 2023 · 1 comment
Assignees
Labels

Comments

@iloveeclipse
Copy link
Member

For the trivially wrong test code below (derived from a more complex text case where some code was per mistake added after fail()), spotbugs 4.8.0 reports an execution error.

package xxx;
public class Regression {
    public void testUnreachableCode() {
        org.junit.Assert.fail();
        System.err.println("Not reachable code");
    }
}

Error reported:

java.lang.IllegalArgumentException: 0 is not a value stack offset
	at edu.umd.cs.findbugs.OpcodeStack.getStackItem(OpcodeStack.java:3277)
	at edu.umd.cs.findbugs.detect.DumbMethods$NullMethodsSubDetector.sawOpcode(DumbMethods.java:175)
	at edu.umd.cs.findbugs.detect.DumbMethods.sawOpcode(DumbMethods.java:916)
	at edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit(DismantleBytecode.java:878)
	at edu.umd.cs.findbugs.detect.DumbMethods.visit(DumbMethods.java:1565)
	at edu.umd.cs.findbugs.visitclass.BetterVisitor.visitCode(BetterVisitor.java:218)
	at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitCode(PreorderVisitor.java:250)
	at edu.umd.cs.findbugs.bcel.OpcodeStackDetector.visitCode(OpcodeStackDetector.java:65)
	at org.apache.bcel.classfile.Code.accept(Code.java:121)
	at edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:322)
	at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:404)
	at org.apache.bcel.classfile.JavaClass.accept(JavaClass.java:244)
	at edu.umd.cs.findbugs.BytecodeScanningDetector.visitClassContext(BytecodeScanningDetector.java:38)
	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:264)
	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)
@hazendaz
Copy link
Member

fixed in #2643

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

No branches or pull requests

3 participants