Closed arpitkath closed 5 years ago
Check SpotBugsRule
class, here is sample usage.
SpotBugsRule
class is in test package, so how can I use that in my code?
If not, you can read its implementation to understand how FindBugs2
class is working.
I was trying to do the same as given in SpotBugsRule
file, which uses FindBugs2
internally.
Was getting the following stack trace while executing FindBugs2 engine = new FindBugs2();
, which belongs to line private static final boolean LIST_ORDER = SystemProperties.getBoolean("findbugs.listOrder");
(line 85: FindBugs2.class
)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at edu.umd.cs.findbugs.PluginLoader.loadPluginComponents(PluginLoader.java:837)
at edu.umd.cs.findbugs.PluginLoader.<init>(PluginLoader.java:397)
at edu.umd.cs.findbugs.PluginLoader.loadCorePlugin(PluginLoader.java:1486)
at edu.umd.cs.findbugs.PluginLoader.loadInitialPlugins(PluginLoader.java:1440)
at edu.umd.cs.findbugs.PluginLoader.<clinit>(PluginLoader.java:150)
at edu.umd.cs.findbugs.DetectorFactoryCollection.getCoreResource(DetectorFactoryCollection.java:351)
at edu.umd.cs.findbugs.SystemProperties.loadPropertiesFromConfigFile(SystemProperties.java:77)
at edu.umd.cs.findbugs.SystemProperties.<clinit>(SystemProperties.java:60)
at edu.umd.cs.findbugs.FindBugs2.<clinit>(FindBugs2.java:85)
Sorry I cannot get your point, which problem you faced?
When I tried to execute IFindBugsEngine engine = new FindBugs2();
, I got the above stack trace.
The above stack trace initiates in FindBugs2
class, line number 85.
Not able to run this simple code. Getting the above stack trace for the following code.
import edu.umd.cs.findbugs.FindBugs2;
import edu.umd.cs.findbugs.IFindBugsEngine;
public class Hello {
public static void main(String args[]) {
IFindBugsEngine fb = new FindBugs2();
}
}
Wmm not reproducible... I guess that you have some trouble around plugin.
at edu.umd.cs.findbugs.PluginLoader.loadPluginComponents(PluginLoader.java:837)
I'll close this stale issue. If necessary, please reopen it freely.
I was working on injecting of groovy scripts dynamically in Java. So before executing those scripts, I want to get sure of that they do not have potential bugs using SpotBugs. Here is the Psuedo-Code:
So how to do the
SpotBugs.getBugs(script)
using java, the inputscript
will not be hard-coded as in above example, but will be dynamically fetched.