Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 17, 2023
2 parents 7e5e7d7 + bb9c610 commit b3289a8
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 7 deletions.
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<threshold>Normal</threshold>
<effort>Default</effort>
<excludeFilterFile>src/conf/spotbugs-exclude-filter.xml</excludeFilterFile>
<!-- Hacky: Don't allow new SpotBugs errors -->
<maxAllowedViolations>9</maxAllowedViolations>
</configuration>
</plugin>
<plugin>
Expand Down
69 changes: 66 additions & 3 deletions src/conf/spotbugs-exclude-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,29 @@

<!-- Binary compatibility -->
<Match>
<Bug pattern="EI_EXPOSE_STATIC_REP2"/>
<Method name="clone"/>
<Class name="org\.apache\.bcel\.Repository"/>
<Class name="org.apache.bcel.Repository"/>
<Method name="setRepository"/>
<Bug pattern="EI_EXPOSE_STATIC_REP2"/>
</Match>

<Match>
<Class name="org.apache.bcel.Repository"/>
<Method name="getRepository"/>
<Bug pattern="MS_EXPOSE_REP"/>
</Match>


<!--
TODO: this should probably be sinplified
Medium: Complicated, subtle or wrong increment in for-loop
org.apache.bcel.util.BCELifier.printFlags(int, BCELifier$FLAGS)
[org.apache.bcel.util.BCELifier] At BCELifier.java:[line 118]
QF_QUESTIONABLE_FOR_LOOP
-->
<Match>
<Class name="org.apache.bcel.util.BCELifier"/>
<Method name="printFlags" params="int, org.apache.bcel.util.BCELifier$FLAGS" returns="java.lang.String"/>
<Bug pattern="QF_QUESTIONABLE_FOR_LOOP"/>
</Match>

<!-- Reason: TODO, perhaps? -->
Expand All @@ -91,4 +110,48 @@
</Or>
</Match>

<!--
This is intentional
Error: Switch statement found in org.apache.bcel.util.BCELFactory.visitAllocationInstruction(AllocationInstruction)
where one case falls through to the next case
[org.apache.bcel.util.BCELFactory, org.apache.bcel.util.BCELFactory]
At BCELFactory.java:[lines 188-191]
Another occurrence at BCELFactory.java:[lines 192-196] SF_SWITCH_FALLTHROUGH
-->
<Match>
<Class name="org.apache.bcel.util.BCELFactory"/>
<Method name="visitAllocationInstruction"/>
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
</Match>

<!--
Class is deprecated
Error: The class name org.apache.bcel.util.ClassLoader
shadows the simple name of the superclass java.lang.ClassLoader
[org.apache.bcel.util.ClassLoader] At ClassLoader.java:[lines 59-178]
NM_SAME_SIMPLE_NAME_AS_SUPERCLASS
Error: org.apache.bcel.util.ClassLoader.DEFAULT_IGNORED_PACKAGES should be package protected
[org.apache.bcel.util.ClassLoader] At ClassLoader.java:[line 59]
MS_PKGPROTECT
-->
<Match>
<Class name="org.apache.bcel.util.ClassLoader"/>
<Or>
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
<Bug pattern="MS_PKGPROTECT"/>
</Or>
</Match>

<!--
TODO: field is deprecated in preparation for making it private later
Error: org.apache.bcel.verifier.structurals.Frame._this should be package protected
[org.apache.bcel.verifier.structurals.Frame] In Frame.java
MS_PKGPROTECT
-->
<Match>
<Class name="org.apache.bcel.verifier.structurals.Frame"/>
<Field name="_this"/>
<Bug pattern="MS_PKGPROTECT"/>
</Match>

</FindBugsFilter>
9 changes: 7 additions & 2 deletions src/main/java/org/apache/bcel/classfile/ConstantUtf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ static void printStats() {
Cache.MAX_ENTRY_SIZE);
}

// Avoid Spotbugs complaint about Write to static field
private static void countCreated() {
created++;
}

private final String value;

/**
Expand All @@ -198,7 +203,7 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
ConstantUtf8(final DataInput dataInput) throws IOException {
super(Const.CONSTANT_Utf8);
value = dataInput.readUTF();
created++;
countCreated();
}

/**
Expand All @@ -207,7 +212,7 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
public ConstantUtf8(final String value) {
super(Const.CONSTANT_Utf8);
this.value = Objects.requireNonNull(value, "value");
created++;
countCreated();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/apache/bcel/generic/InstructionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,9 @@ public void setPositions(final boolean check) { // called by code in other packa
case Const.LOOKUPSWITCH:
maxAdditionalBytes += 3;
break;
default:
// TODO should this be an error?
break;
}
index += i.getLength();
}
Expand Down

0 comments on commit b3289a8

Please sign in to comment.