Skip to content

Closed handle long constant values in the OpcodeStack #688

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

Merged
merged 6 commits into from
Jul 9, 2018

Conversation

KengoTODA
Copy link
Member

Same with #514 but rebased on the top of release-3.1 branch.

@KengoTODA KengoTODA added the bug label Jul 5, 2018
@KengoTODA KengoTODA added this to the SpotBugs 3.1.6 milestone Jul 5, 2018
@KengoTODA KengoTODA changed the title Fix 514 Closed handle long constant values in the OpcodeStack Jul 5, 2018
ThrawnCA
ThrawnCA previously approved these changes Jul 5, 2018
@KengoTODA
Copy link
Member Author

KengoTODA commented Jul 5, 2018

Currently we have test failures like below:

Error processing opcode invokestatic @ 531 in java.lang.invoke.MethodHandles.loop : ([[Ljava.lang.invoke.MethodHandle;)Ljava.lang.invoke.MethodHandle;
    java.lang.IllegalArgumentException: Unknown signature for number: Ljava/lang/Boolean;
      At edu.umd.cs.findbugs.OpcodeStack$Item.<init>(OpcodeStack.java:659)
      At edu.umd.cs.findbugs.OpcodeStack.processMethodCall(OpcodeStack.java:2504)
      At edu.umd.cs.findbugs.OpcodeStack.sawOpcode(OpcodeStack.java:2152)
Error processing opcode invokestatic @ 2 in gcUnrelatedTypes.ListTests.test2Bugs : (Ljava.util.LinkedList;)V
    java.lang.IllegalArgumentException: Unknown signature for number: Ljava/lang/Integer;

@ThrawnCA
Copy link
Contributor

ThrawnCA commented Jul 6, 2018

How is that possible when we've checked that constValue is a Number?

Edit: Hang on, where are we even getting constValue from in this case? It's in a constructor and that's not one of the arguments...

@KengoTODA
Copy link
Member Author

KengoTODA commented Jul 6, 2018

It happens in MethodHandle class updated by Java9. I guess that Java9 javac changed some behavior, but cannot find related document.

→Update: it is not related with javac behavior, it it caused just by new implementation in MethodHandles.loop() method. i could reproduce it with Java8, see unit test in this PR.

@spotbugs spotbugs deleted a comment from ThrawnCA Jul 6, 2018
@spotbugs spotbugs deleted a comment from KengoTODA Jul 6, 2018
@KengoTODA
Copy link
Member Author

@ThrawnCA please have a review again, I've added test case to reproduce problem with java.lang.Boolean constant value.

@spotbugs-bot
Copy link
Member

SonarQube analysis reported 4 issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. MAJOR OpcodeStack.java#L2808: Merge this if statement with the enclosing one. rule
  2. MAJOR OpcodeStack.java#L3024: Merge this if statement with the enclosing one. rule
  3. MAJOR OpcodeStack.java#L3722: Remove these unused method parameters. rule
  4. MINOR OpcodeStack.java#L3023: Use isEmpty() to check whether the collection is empty or not. rule

Copy link
Contributor

@ThrawnCA ThrawnCA left a comment

Choose a reason for hiding this comment

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

Really? We need to handle booleans and arrays as if they were numbers?

Eww. I'll approve, but eww.

@KengoTODA
Copy link
Member Author

Not array, just a boxed types. I'll merge this PR.

@KengoTODA KengoTODA merged commit 8b1045e into release-3.1 Jul 9, 2018
@KengoTODA KengoTODA deleted the fix-514 branch July 9, 2018 02:34
@ThrawnCA
Copy link
Contributor

ThrawnCA commented Jul 9, 2018

Wait, I remember this. @mebigfatguy Didn't you discover that the compiler saves array length as a constValue?

Edit: Found it: mebigfatguy/fb-contrib#40 (comment)
Looks like this is something SpotBugs is doing to itself.

@ThrawnCA
Copy link
Contributor

@mebigfatguy Bump. I know this is merged, but do you have more insight on what the compiler is doing here?

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

Successfully merging this pull request may close these issues.

4 participants