Skip to content

Commit 45faae7

Browse files
committed
Merge remote-tracking branch 'spotbugs/master' into issue-60
2 parents 14cddb8 + 9b8eaa3 commit 45faae7

File tree

108 files changed

+539
-1163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+539
-1163
lines changed

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
subprojects {
22
apply plugin: 'java'
3+
apply plugin: 'maven-publish'
34
apply from: "$rootDir/gradle/eclipse.gradle"
45
apply from: "$rootDir/gradle/idea.gradle"
56
apply from: "$rootDir/gradle/test.gradle"

findbugs/build.gradle

+42-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ configurations {
3030

3131
dependencies {
3232
compile 'org.ow2.asm:asm-debug-all:6.0_ALPHA'
33+
compile 'net.jcip:jcip-annotations:1.0'
3334

3435
// TODO : Some of these can be extracted to actual dependencies
3536
compile fileTree(dir: 'lib', include: '*.jar')
@@ -75,11 +76,17 @@ task annotationsJar(type:Jar) {
7576
from(sourceSets.main.output) {
7677
include '**/annotations/*'
7778
}
78-
// TODO : These includes source java files.. exclude them and put them in a separate sources jar?
79-
from zipTree("$projectDir/lib/jcip-annotations.jar").matching {
80-
exclude 'META-INF/**'
81-
exclude '**/*.html'
79+
80+
from {
81+
configurations.compile.filter {
82+
it.name.startsWith('jcip-annotations')
83+
} collect {
84+
zipTree(it).matching {
85+
exclude 'META-INF/**'
86+
}
87+
}
8288
}
89+
8390
from zipTree("$projectDir/lib/jsr305.jar").matching { // TODO : to be dropped
8491
exclude 'META-INF/**'
8592
exclude '**/*.html'
@@ -254,6 +261,37 @@ task smokeTest {
254261
}
255262
}
256263

264+
// https://docs.gradle.org/current/userguide/publishing_maven.html
265+
publishing {
266+
publications {
267+
mavenJava(MavenPublication) {
268+
from components.java
269+
artifactId 'spotbugs'
270+
271+
artifact sourcesJar {
272+
classifier 'sources'
273+
}
274+
275+
artifact javadocJar {
276+
classifier 'javadoc'
277+
}
278+
}
279+
280+
annotations(MavenPublication) {
281+
artifactId 'spotbugs-annotations'
282+
artifact annotationsJar
283+
284+
artifact annotationSourcesJar {
285+
classifier 'sources'
286+
}
287+
288+
artifact annotationJavadocJar {
289+
classifier 'javadoc'
290+
}
291+
}
292+
}
293+
}
294+
257295
// TODO : jsr305.jar (really?)
258296
// TODO : generatemanual (we should decide what to do with the manual)
259297
// TODO : generatepdfmanual

findbugs/lib/jcip-annotations.jar

-6.41 KB
Binary file not shown.

findbugs/src/main/java/edu/umd/cs/findbugs/BugInstance.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import javax.annotation.Nonnull;
4545
import javax.annotation.meta.When;
4646

47-
import org.apache.bcel.Constants;
47+
import org.apache.bcel.Const;
4848
import org.apache.bcel.classfile.JavaClass;
4949
import org.apache.bcel.classfile.Method;
5050
import org.apache.bcel.generic.ConstantPoolGen;
@@ -68,7 +68,6 @@
6868
import edu.umd.cs.findbugs.ba.XMethod;
6969
import edu.umd.cs.findbugs.ba.bcp.FieldVariable;
7070
import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
71-
import edu.umd.cs.findbugs.bcel.BCELUtil;
7271
import edu.umd.cs.findbugs.bytecode.MemberUtils;
7372
import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
7473
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
@@ -1465,7 +1464,7 @@ public BugInstance addCalledMethod(ConstantPoolGen cpg, InvokeInstruction inv) {
14651464
String className = inv.getClassName(cpg);
14661465
String methodName = inv.getMethodName(cpg);
14671466
String methodSig = inv.getSignature(cpg);
1468-
addMethod(className, methodName, methodSig, inv.getOpcode() == Constants.INVOKESTATIC);
1467+
addMethod(className, methodName, methodSig, inv.getOpcode() == Const.INVOKESTATIC);
14691468
describe(MethodAnnotation.METHOD_CALLED);
14701469
return this;
14711470
}

findbugs/src/main/java/edu/umd/cs/findbugs/FieldAnnotation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
import org.apache.bcel.Constants;
24+
import org.apache.bcel.Const;
2525
import org.apache.bcel.classfile.Field;
2626
import org.apache.bcel.classfile.JavaClass;
2727
import org.apache.bcel.generic.ConstantPoolGen;
@@ -116,7 +116,7 @@ public FieldAnnotation(@DottedClassName String className, String fieldName, Stri
116116
* accessFlags for the field
117117
*/
118118
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, int accessFlags) {
119-
this(className, fieldName, fieldSig, (accessFlags & Constants.ACC_STATIC) != 0);
119+
this(className, fieldName, fieldSig, (accessFlags & Const.ACC_STATIC) != 0);
120120
}
121121

122122
/**

findbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
import org.apache.bcel.Constants;
24+
import org.apache.bcel.Const;
2525

2626
import edu.umd.cs.findbugs.ba.AnalysisContext;
2727
import edu.umd.cs.findbugs.ba.SignatureConverter;
@@ -145,7 +145,7 @@ public static MethodAnnotation fromCalledMethod(DismantleBytecode visitor) {
145145
String methodName = visitor.getNameConstantOperand();
146146
String methodSig = visitor.getSigConstantOperand();
147147

148-
if (visitor instanceof OpcodeStackDetector && visitor.getOpcode() != Constants.INVOKESTATIC) {
148+
if (visitor instanceof OpcodeStackDetector && visitor.getOpcode() != Const.INVOKESTATIC) {
149149
int params = PreorderVisitor.getNumberArguments(methodSig);
150150
OpcodeStackDetector oVisitor = (OpcodeStackDetector) visitor;
151151
if (!oVisitor.getStack().isTop() && oVisitor.getStack().getStackDepth() > params) {
@@ -159,7 +159,7 @@ public static MethodAnnotation fromCalledMethod(DismantleBytecode visitor) {
159159

160160
}
161161

162-
return fromCalledMethod(className, methodName, methodSig, visitor.getOpcode() == Constants.INVOKESTATIC);
162+
return fromCalledMethod(className, methodName, methodSig, visitor.getOpcode() == Const.INVOKESTATIC);
163163
}
164164

165165
/**
@@ -184,7 +184,7 @@ public static MethodAnnotation fromForeignMethod(@SlashedClassName String classN
184184
// Create MethodAnnotation.
185185
// It won't have source lines yet.
186186
MethodAnnotation methodAnnotation = new MethodAnnotation(className, methodName, methodSig,
187-
(accessFlags & Constants.ACC_STATIC) != 0);
187+
(accessFlags & Const.ACC_STATIC) != 0);
188188

189189
SourceLineAnnotation sourceLines = SourceLineAnnotation.getSourceAnnotationForMethod(className, methodName, methodSig);
190190

findbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public PluginLoader() throws PluginException {
402402
* Fake plugin.
403403
*/
404404
@Deprecated
405-
public PluginLoader(boolean fake, URL url) throws PluginException {
405+
public PluginLoader(boolean fake, URL url) {
406406
classLoader = getClass().getClassLoader();
407407
classLoaderForResources = classLoader;
408408
corePlugin = false;

findbugs/src/main/java/edu/umd/cs/findbugs/SwitchHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import javax.annotation.CheckForNull;
2626

27-
import org.apache.bcel.Constants;
27+
import org.apache.bcel.Const;
2828

2929
import edu.umd.cs.findbugs.ba.XClass;
3030
import edu.umd.cs.findbugs.ba.XField;
@@ -55,7 +55,7 @@ int numEnumValues(@CheckForNull XClass c) {
5555

5656
public void enterSwitch(DismantleBytecode dbc, @CheckForNull XClass enumType) {
5757

58-
assert dbc.getOpcode() == Constants.TABLESWITCH || dbc.getOpcode() == Constants.LOOKUPSWITCH;
58+
assert dbc.getOpcode() == Const.TABLESWITCH || dbc.getOpcode() == Const.LOOKUPSWITCH;
5959
int[] switchOffsets = dbc.getSwitchOffsets();
6060
SwitchDetails details = new SwitchDetails(dbc.getPC(), switchOffsets, dbc.getDefaultSwitchOffset(), switchOffsets.length == numEnumValues(enumType));
6161

findbugs/src/main/java/edu/umd/cs/findbugs/TypeAnnotation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public TypeAnnotation(String typeDescriptor, String roleDescription) {
8989
descriptor = typeDescriptor;
9090
this.roleDescription = roleDescription;
9191
if (descriptor.startsWith("L")) {
92-
String className = typeDescriptor.substring(1, typeDescriptor.length() - 1).replace('/', '.');
9392
AnalysisContext context = AnalysisContext.currentAnalysisContext();
9493
if (context != null) {
94+
String className = typeDescriptor.substring(1, typeDescriptor.length() - 1).replace('/', '.');
9595
this.sourceFileName = context.lookupSourceFile(className);
9696
this.sourceLines = ClassAnnotation.getSourceLinesForClass(className, sourceFileName);
9797
} else {

findbugs/src/main/java/edu/umd/cs/findbugs/ba/AbstractClassMember.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
package edu.umd.cs.findbugs.ba;
2020

21-
import org.apache.bcel.Constants;
21+
import org.apache.bcel.Const;
2222

2323
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
2424
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
@@ -109,27 +109,27 @@ public int getAccessFlags() {
109109

110110
@Override
111111
public boolean isStatic() {
112-
return (accessFlags & Constants.ACC_STATIC) != 0;
112+
return (accessFlags & Const.ACC_STATIC) != 0;
113113
}
114114

115115
@Override
116116
public boolean isFinal() {
117-
return (accessFlags & Constants.ACC_FINAL) != 0;
117+
return (accessFlags & Const.ACC_FINAL) != 0;
118118
}
119119

120120
@Override
121121
public boolean isPublic() {
122-
return (accessFlags & Constants.ACC_PUBLIC) != 0;
122+
return (accessFlags & Const.ACC_PUBLIC) != 0;
123123
}
124124

125125
@Override
126126
public boolean isProtected() {
127-
return (accessFlags & Constants.ACC_PROTECTED) != 0;
127+
return (accessFlags & Const.ACC_PROTECTED) != 0;
128128
}
129129

130130
@Override
131131
public boolean isPrivate() {
132-
return (accessFlags & Constants.ACC_PRIVATE) != 0;
132+
return (accessFlags & Const.ACC_PRIVATE) != 0;
133133
}
134134

135135
// public int compareTo(ClassMember other) {

findbugs/src/main/java/edu/umd/cs/findbugs/ba/AbstractField.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package edu.umd.cs.findbugs.ba;
2121

22-
import org.apache.bcel.Constants;
22+
import org.apache.bcel.Const;
2323

2424
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
2525
import edu.umd.cs.findbugs.classfile.FieldDescriptor;
@@ -33,17 +33,17 @@ protected AbstractField(@DottedClassName String className, String fieldName, Str
3333

3434
@Override
3535
public boolean isVolatile() {
36-
return (getAccessFlags() & Constants.ACC_VOLATILE) != 0;
36+
return (getAccessFlags() & Const.ACC_VOLATILE) != 0;
3737
}
3838

3939
@Override
4040
public final boolean isSynthetic() {
41-
return (getAccessFlags() & Constants.ACC_SYNTHETIC) != 0;
41+
return (getAccessFlags() & Const.ACC_SYNTHETIC) != 0;
4242
}
4343

4444
@Override
4545
public boolean isEnum() {
46-
return (getAccessFlags() & Constants.ACC_ENUM) != 0;
46+
return (getAccessFlags() & Const.ACC_ENUM) != 0;
4747
}
4848

4949
/*

findbugs/src/main/java/edu/umd/cs/findbugs/ba/AbstractFrameModelingVisitor.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package edu.umd.cs.findbugs.ba;
2121

22-
import org.apache.bcel.Constants;
22+
import org.apache.bcel.Const;
2323
import org.apache.bcel.generic.*;
2424

2525
import edu.umd.cs.findbugs.bcel.generic.NONNULL2Z;
@@ -139,7 +139,7 @@ public Location getLocation() {
139139
*/
140140
public int getNumWordsConsumed(Instruction ins) {
141141
int numWordsConsumed = ins.consumeStack(cpg);
142-
if (numWordsConsumed == Constants.UNPREDICTABLE) {
142+
if (numWordsConsumed == Const.UNPREDICTABLE) {
143143
throw new InvalidBytecodeException("Unpredictable stack consumption");
144144
}
145145
return numWordsConsumed;
@@ -151,7 +151,7 @@ public int getNumWordsConsumed(Instruction ins) {
151151
public int getNumWordsProduced(Instruction ins) {
152152

153153
int numWordsProduced = ins.produceStack(cpg);
154-
if (numWordsProduced == Constants.UNPREDICTABLE) {
154+
if (numWordsProduced == Const.UNPREDICTABLE) {
155155
throw new InvalidBytecodeException("Unpredictable stack productions");
156156
}
157157
return numWordsProduced;
@@ -311,7 +311,7 @@ public void visitStackConsumer(StackConsumer obj) {
311311
public void handleStoreInstruction(StoreInstruction obj) {
312312
try {
313313
int numConsumed = obj.consumeStack(cpg);
314-
if (numConsumed == Constants.UNPREDICTABLE) {
314+
if (numConsumed == Const.UNPREDICTABLE) {
315315
throw new InvalidBytecodeException("Unpredictable stack consumption");
316316
}
317317

@@ -335,7 +335,7 @@ public void handleStoreInstruction(StoreInstruction obj) {
335335
*/
336336
public void handleLoadInstruction(LoadInstruction obj) {
337337
int numProduced = obj.produceStack(cpg);
338-
if (numProduced == Constants.UNPREDICTABLE) {
338+
if (numProduced == Const.UNPREDICTABLE) {
339339
throw new InvalidBytecodeException("Unpredictable stack production");
340340
}
341341

findbugs/src/main/java/edu/umd/cs/findbugs/ba/AbstractMethod.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
package edu.umd.cs.findbugs.ba;
2020

21-
import org.apache.bcel.Constants;
21+
import org.apache.bcel.Const;
2222

2323
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
2424
import edu.umd.cs.findbugs.classfile.MethodDescriptor;
@@ -39,17 +39,17 @@ public int getNumParams() {
3939

4040
@Override
4141
public boolean isNative() {
42-
return (getAccessFlags() & Constants.ACC_NATIVE) != 0;
42+
return (getAccessFlags() & Const.ACC_NATIVE) != 0;
4343
}
4444

4545
@Override
4646
public boolean isSynchronized() {
47-
return (getAccessFlags() & Constants.ACC_SYNCHRONIZED) != 0;
47+
return (getAccessFlags() & Const.ACC_SYNCHRONIZED) != 0;
4848
}
4949

5050
@Override
5151
public boolean isBridge() {
52-
return (getAccessFlags() & Constants.ACC_BRIDGE) != 0;
52+
return (getAccessFlags() & Const.ACC_BRIDGE) != 0;
5353
}
5454

5555
@Override

findbugs/src/main/java/edu/umd/cs/findbugs/ba/AssignedFieldMap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class AssignedFieldMap implements Constants {
8282
* ConstantPoolGen cpg = methodGen.getConstantPool();
8383
*
8484
* while (handle != null) { Instruction ins = handle.getInstruction(); short
85-
* opcode = ins.getOpcode(); if (opcode == Constants.PUTFIELD) { PUTFIELD
85+
* opcode = ins.getOpcode(); if (opcode == Const.PUTFIELD) { PUTFIELD
8686
* putfield = (PUTFIELD) ins;
8787
*
8888
* XField instanceField = Hierarchy.findXField(putfield, cpg); if

0 commit comments

Comments
 (0)