Comments (10)
@KengoTODA the exception does occur, but is managed and simply logged to stderr without the test failing.
from spotbugs.
I will try to reproduce this in issue-20
branch.
from spotbugs.
I'm still testing #61, which is necessary to test your class with our integration test. Here is current patch:
diff --git a/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java b/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java
new file mode 100644
index 0000000..a767df9
--- /dev/null
+++ b/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java
@@ -0,0 +1,22 @@
+package edu.umd.cs.findbugs.detect;
+
+import static org.junit.Assert.assertThat;
+
+import static org.hamcrest.core.Is.is;
+
+import static org.hamcrest.collection.IsEmptyIterable.*;
+import org.junit.Test;
+
+import edu.umd.cs.findbugs.AbstractIntegrationTest;
+
+public class FindUnsatisfiedObligationTest extends AbstractIntegrationTest {
+ /**
+ * @see <a href="https://github.com/spotbugs/spotbugs/issues/60">GitHub
+ * issue</a>
+ */
+ @Test
+ public void testIssue60() {
+ performAnalysis("Issue60.class");
+ assertThat(getBugCollection(), is(emptyIterable()));
+ }
+}
diff --git a/findbugsTestCases/src/java/Issue60.java b/findbugsTestCases/src/java/Issue60.java
new file mode 100644
index 0000000..b79f1b8
--- /dev/null
+++ b/findbugsTestCases/src/java/Issue60.java
@@ -0,0 +1,22 @@
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+import java.util.stream.Stream;
+
+public class Issue60 {
+
+ public static void create(URL url) {
+ try (InputStream in = url.openStream()) {
+ Properties p1 = new Properties();
+ p1.load(in);
+ } catch (IOException e) {
+ }
+ }
+
+ public Stream<String> keys() {
+ return Stream.<Properties> of()
+ .flatMap(p -> p.stringPropertyNames().stream());
+ }
+
+}
from spotbugs.
By #69, I confirmed that current master
branch has no problem. @barney2k7 please have a try.
from spotbugs.
@jsotuyod Oh... I also confirmed this behaviour. I will try to update AbstractIntegrationTest
to mark our build as failed.
from spotbugs.
Running javap
on the compiled source we can see the offending code:
public java.util.stream.Stream<java.lang.String> keys();
descriptor: ()Ljava/util/stream/Stream;
flags: ACC_PUBLIC
Code:
stack=2, locals=1, args_size=1
0: iconst_0
1: anewarray #3 // class java/util/Properties
4: invokestatic #10 // InterfaceMethod java/util/stream/Stream.of:([Ljava/lang/Object;)Ljava/util/stream/Stream;
7: invokedynamic #11, 0 // InvokeDynamic #0:apply:()Ljava/util/function/Function;
And in the constant pool we can see:
Constant pool:
#1 = Methodref #16.#46 // java/lang/Object."<init>":()V
#2 = Methodref #47.#48 // java/net/URL.openStream:()Ljava/io/InputStream;
#3 = Class #49 // java/util/Properties
#4 = Methodref #3.#46 // java/util/Properties."<init>":()V
#5 = Methodref #3.#50 // java/util/Properties.load:(Ljava/io/InputStream;)V
#6 = Methodref #51.#52 // java/io/InputStream.close:()V
#7 = Class #53 // java/lang/Throwable
#8 = Methodref #7.#54 // java/lang/Throwable.addSuppressed:(Ljava/lang/Throwable;)V
#9 = Class #55 // java/io/IOException
#10 = InterfaceMethodref #56.#57 // java/util/stream/Stream.of:([Ljava/lang/Object;)Ljava/util/stream/Stream;
#11 = InvokeDynamic #0:#63 // #0:apply:()Ljava/util/function/Function;
This happens because the invokedynamic
is acting on the method handle, which of course, has no class name.
This is a bug on BCEL, that should override getReferenceType
on INVOKEDYNAMIC
to at least not throw a ClassFormatException
. What do you think @mebigfatguy ?
In the meantime, we may rewrite the detector to handle INVOKEDYNAMIC
separately.
from spotbugs.
yeah, should add a bug here http://issues.apache.org/jira/browse/BCEL
from spotbugs.
i suppose it should return Object?or....? i'll add it.
https://issues.apache.org/jira/browse/BCEL-284
from spotbugs.
You are amazing! Thanks for the quick fix
I guess for the time being we can wait for a BCEL 6.1 release / use a snapshot until we reach the point of releasing Spotbugs 3.1.0
from spotbugs.
This problem should be solved by #69. I will close this issue.
from spotbugs.
Related Issues (20)
- Prefix matching behavior of SuppressFBWarnings makes it impossible to suppress just one warning HOT 2
- DataflowAnalysisException in 4.7.3 and 4.8.3 HOT 5
- Preview mode for new/enhanced detectors HOT 2
- How to get line number of method in Interface HOT 1
- Spotbugs 4.8.4 release notes missing in GitHub HOT 5
- MC_OVERRIDABLE_METHOD_CALL_IN_READ_OBJECT false positive in 4.8.4 HOT 14
- Test classes for issue 574 are in the wrong package HOT 1
- Failing while building spotbugs version 4.2.3 using ./gradlew build HOT 5
- Change the release process to automate the changelog HOT 1
- False positive SING_SINGLETON_IMPLEMENTS_SERIALIZABLE when class is not a singleton HOT 3
- Still getting NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE with Objects.requireNonNull
- Version 4.8.4 false positive SING_SINGLETON_GETTER_NOT_SYNCHRONIZED HOT 6
- False positive BC_IMPOSSIBLE_INSTANCEOF HOT 4
- Stylesheet not working in 4.8.4 HOT 6
- Signature of eclipse-plugin expired HOT 1
- FP SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR for record HOT 4
- CT_CONSTRUCTOR_THROW: report violation for final fields HOT 2
- Another false positive SING_SINGLETON_IMPLEMENTS_SERIALIZABLE when class is not a singleton (e.g. protobuf) HOT 1
- Array index out of bounds exception on `FindDeadLocalStores` HOT 4
- Index out of bounds for empty switch HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spotbugs.