You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/19 04:16:34 UTC
[commons-bcel] branch master updated: Refactor duplicate code
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new 7168c854 Refactor duplicate code
7168c854 is described below
commit 7168c8548862601679d4b78c70b47a452ee03be6
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Fri Nov 18 23:16:30 2022 -0500
Refactor duplicate code
---
.../java/org/apache/bcel/classfile/StackMapType.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapType.java b/src/main/java/org/apache/bcel/classfile/StackMapType.java
index 3338dd3e..fcf5a064 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapType.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapType.java
@@ -40,10 +40,7 @@ public final class StackMapType implements Cloneable {
* @param index index to constant pool, or byte code offset
*/
public StackMapType(final byte type, final int index, final ConstantPool constantPool) {
- if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) {
- throw new IllegalArgumentException("Illegal type for StackMapType: " + type);
- }
- this.type = type;
+ this.type = checkType(type);
this.index = index;
this.constantPool = constantPool;
}
@@ -62,6 +59,13 @@ public final class StackMapType implements Cloneable {
this.constantPool = constantPool;
}
+ private byte checkType(final byte t) {
+ if (t < Const.ITEM_Bogus || t > Const.ITEM_NewObject) {
+ throw new IllegalArgumentException("Illegal type for StackMapType: " + t);
+ }
+ return t;
+ }
+
/**
* @return deep copy of this object
*/
@@ -138,10 +142,7 @@ public final class StackMapType implements Cloneable {
}
public void setType(final byte t) {
- if (t < Const.ITEM_Bogus || t > Const.ITEM_NewObject) {
- throw new IllegalArgumentException("Illegal type for StackMapType: " + t);
- }
- type = t;
+ type = checkType(t);
}
/**