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.IllegalArgumentException: true #893

Closed
ctmay4 opened this issue Mar 1, 2019 · 3 comments
Closed

java.lang.IllegalArgumentException: true #893

ctmay4 opened this issue Mar 1, 2019 · 3 comments
Assignees

Comments

@ctmay4
Copy link

ctmay4 commented Mar 1, 2019

I was hoping 3.1.12 was going to fix this analysis error but I just updated and it is still there. I've had this ever since switching from FindBugs to Spotbugs. My build run under Java 11. Here is one of the errors I get in my log (I get many like it):

 The following errors occurred during analysis:
   Error processing2 < Z, signed_byte, true, return value from java.lang.Boolean.booleanValue()Z, r3 >iand< Z, return value from com.imsweb.seerdms.app.autobuild.AutoBuildUtils.compareFieldValues(Ljava/lang/Object;Ljava/lang/Object;)Z > @ 55 in com.imsweb.seerdms.app.autobuild.AutoBuildUtils.compareTxs : (Lcom.imsweb.seerdms.shared.entity.TreatmentProcedure;Lcom.imsweb.seerdms.shared.entity.TreatmentProcedure;)Z
     java.lang.IllegalArgumentException: true
       At edu.umd.cs.findbugs.OpcodeStack.constantToInt(OpcodeStack.java:2239)
       At edu.umd.cs.findbugs.OpcodeStack.pushByIntMath(OpcodeStack.java:3358)
       At edu.umd.cs.findbugs.OpcodeStack.sawOpcode(OpcodeStack.java:1914)
       At edu.umd.cs.findbugs.OpcodeStack$JumpInfoFactory$JumpStackComputation.sawOpcode(OpcodeStack.java:2940)
       At edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit(DismantleBytecode.java:882)
       At edu.umd.cs.findbugs.visitclass.BetterVisitor.visitCode(BetterVisitor.java:218)
       At edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitCode(PreorderVisitor.java:243)
       At edu.umd.cs.findbugs.OpcodeStack$JumpInfoFactory$JumpStackComputation.visitCode(OpcodeStack.java:2926)
       At org.apache.bcel.classfile.Code.accept(Code.java:132)
       At edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:315)
       At edu.umd.cs.findbugs.OpcodeStack$JumpInfoFactory.computeJumpInfo(OpcodeStack.java:2970)
       At edu.umd.cs.findbugs.OpcodeStack$JumpInfoFactory.analyze(OpcodeStack.java:2900)
       At edu.umd.cs.findbugs.OpcodeStack$JumpInfoFactory.analyze(OpcodeStack.java:2883)
       At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:369)
       At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:322)
       At edu.umd.cs.findbugs.OpcodeStack.getJumpInfo(OpcodeStack.java:3101)
       At edu.umd.cs.findbugs.OpcodeStack.resetForMethodEntry(OpcodeStack.java:3072)
       At edu.umd.cs.findbugs.bcel.OpcodeStackDetector.visitCode(OpcodeStackDetector.java:64)
       At org.apache.bcel.classfile.Code.accept(Code.java:132)
       At edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:315)
       At edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:403)
       At org.apache.bcel.classfile.JavaClass.accept(JavaClass.java:213)
       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.analyzeApplication(FindBugs2.java:1080)
       At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:281)
       At com.github.spotbugs.internal.spotbugs.SpotBugsExecutor.runSpotbugs(SpotBugsExecutor.java:23)
       At java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       At java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       At java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       At java.base/java.lang.reflect.Method.invoke(Method.java:566)
       At org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:110)
       At org.gradle.process.internal.worker.request.WorkerAction.runThenStop(WorkerAction.java:93)
       At java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       At java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       At java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       At java.base/java.lang.reflect.Method.invoke(Method.java:566)
       At org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
       At org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
       At org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
       At org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
       At org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
       At org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
       At org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
       At java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
       At java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
       At org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
       At java.base/java.lang.Thread.run(Thread.java:834)

The method it is referencing is:

protected boolean compareFieldValues(Object current, Object exist) {
    if (current == null)
        return true;
    else if (exist == null)
        return false;

    return current.equals(exist);
}

public boolean compareTxs(TreatmentProcedure masterTx, TreatmentProcedure compareToTx) {
    // consider this is a duplicate until it finds a field with different value.
    Boolean isDuplicate = true;
    // check standard fields
    for (String field : getDuplicateTxFields())
        isDuplicate &= compareFieldValues(getPropertyValue(masterTx, field), getPropertyValue(compareToTx, field));

    // registry fields
    isDuplicate &= compareRegistryFieldValues(masterTx, compareToTx);

    // check text fields
    if (isDuplicate)
        for (String field : getDuplicateTxTextFields())
            isDuplicate &= compareTxTextField(getPropertyValue(masterTx, field), getPropertyValue(compareToTx, field));

    // check facility
    if (isDuplicate)
        for (String field : getDuplicateTxFacilityFields())
            isDuplicate &= compareTxFacility((Long)getPropertyValue(masterTx, field), (Long)getPropertyValue(compareToTx, field));

    // check subentities
    if (isDuplicate)
        isDuplicate = isDuplicateImage(masterTx.getImageEvaluations(), compareToTx.getImageEvaluations());
    if (isDuplicate)
        isDuplicate = isDuplicateSpecimen(masterTx.getSpecimenEvaluations(), compareToTx.getSpecimenEvaluations());

    return isDuplicate;
}

The log is filled with this but it doesn't affect the build. Spotbugs is not reporting an error just logging a failure.

I looked to see if this was reported but didn't find any mention. Is there a way to turn off these messages?

@philippecade
Copy link

I am seeing this error also on the following kind of code. There are similarities to the previously posted code: a Boolean variable being updated with the &= operator in a loop.

@Override
public boolean isEditorEnabled(AbstractPaCoModel<P> model) {
		
	Boolean result = true;
		
	for(PaCoParameterValuePair<P> pair : this.parameterValuePairs)
	{
		//if the corresponding linked editor is disabled, then disable this one too!
		if(pair.getParameter().getEditorEnabler()!= null 
				&& !pair.getParameter().getEditorEnabler().isEditorEnabled(model)) {
			return false;
		}
			
		boolean isValueMatching = false;
					
		Object objectValue = pair.getValue();
		BOPaCoParameter<P> boParameter = model.getParameter(pair.getParameter());
			
		if(objectValue == null || boParameter == null) {
			return true;
		}
		
		if(objectValue instanceof IPaCoParameterValueEnum)
		{
			isValueMatching = ((IPaCoParameterValueEnum<?>) objectValue).matchesDBValue(boParameter.getValue());
		}else{
			isValueMatching = objectValue.equals(boParameter.getValue());
		}
		
		result &= isValueMatching;
	}
		
	return !result;
}

@iloveeclipse
Copy link
Member

iloveeclipse commented Sep 29, 2020

Sorry not responding earlier, I had the fix locally all the time.
Good observation, that the problem is the &= operator, here is the smallest example that triggers the problem:

public class TestBoolean {
    public void test() throws Exception {
        Boolean b = Boolean.valueOf(false);
        b &= Boolean.valueOf(true);
    }
}

I have a patch, it is trivial.

@iloveeclipse iloveeclipse self-assigned this Sep 29, 2020
iloveeclipse added a commit that referenced this issue Sep 29, 2020
This fixes issue #893

Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
iloveeclipse added a commit that referenced this issue Sep 30, 2020
This fixes issue #893

Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
iloveeclipse added a commit that referenced this issue Sep 30, 2020
This fixes issue #893

Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
iloveeclipse added a commit that referenced this issue Sep 30, 2020
This fixes issue #893

Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
iloveeclipse added a commit that referenced this issue Oct 6, 2020
This fixes issue #893

Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
@iloveeclipse
Copy link
Member

Fixed via #1317

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

3 participants