summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java
diff options
context:
space:
mode:
authorGravatar Thog2017-03-08 08:17:04 +0100
committerGravatar Thog2017-03-08 08:17:04 +0100
commit6e464ea251cab63c776ece0b2a356f1498ffa294 (patch)
tree5ed30c03f5ac4cd2d6877874f5ede576049954f7 /src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java
parentDrop unix case style and implement hashCode when equals is overrided (diff)
downloadenigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.gz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.xz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.zip
Follow Fabric guidelines
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java')
-rw-r--r--src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java b/src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java
index ad5bab0..6ec576e 100644
--- a/src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java
+++ b/src/main/java/cuchaz/enigma/bytecode/ClassProtectifier.java
@@ -8,6 +8,7 @@
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.bytecode; 12package cuchaz.enigma.bytecode;
12 13
13import javassist.CtBehavior; 14import javassist.CtBehavior;
@@ -16,36 +17,35 @@ import javassist.CtField;
16import javassist.bytecode.AccessFlag; 17import javassist.bytecode.AccessFlag;
17import javassist.bytecode.InnerClassesAttribute; 18import javassist.bytecode.InnerClassesAttribute;
18 19
19
20public class ClassProtectifier { 20public class ClassProtectifier {
21 21
22 public static CtClass protectify(CtClass c) { 22 public static CtClass protectify(CtClass c) {
23 23
24 // protectify all the fields 24 // protectify all the fields
25 for (CtField field : c.getDeclaredFields()) { 25 for (CtField field : c.getDeclaredFields()) {
26 field.setModifiers(protectify(field.getModifiers())); 26 field.setModifiers(protectify(field.getModifiers()));
27 } 27 }
28 28
29 // protectify all the methods and constructors 29 // protectify all the methods and constructors
30 for (CtBehavior behavior : c.getDeclaredBehaviors()) { 30 for (CtBehavior behavior : c.getDeclaredBehaviors()) {
31 behavior.setModifiers(protectify(behavior.getModifiers())); 31 behavior.setModifiers(protectify(behavior.getModifiers()));
32 } 32 }
33 33
34 // protectify all the inner classes 34 // protectify all the inner classes
35 InnerClassesAttribute attr = (InnerClassesAttribute) c.getClassFile().getAttribute(InnerClassesAttribute.tag); 35 InnerClassesAttribute attr = (InnerClassesAttribute) c.getClassFile().getAttribute(InnerClassesAttribute.tag);
36 if (attr != null) { 36 if (attr != null) {
37 for (int i = 0; i < attr.tableLength(); i++) { 37 for (int i = 0; i < attr.tableLength(); i++) {
38 attr.setAccessFlags(i, protectify(attr.accessFlags(i))); 38 attr.setAccessFlags(i, protectify(attr.accessFlags(i)));
39 } 39 }
40 } 40 }
41 41
42 return c; 42 return c;
43 } 43 }
44 44
45 private static int protectify(int flags) { 45 private static int protectify(int flags) {
46 if (AccessFlag.isPrivate(flags)) { 46 if (AccessFlag.isPrivate(flags)) {
47 flags = AccessFlag.setProtected(flags); 47 flags = AccessFlag.setProtected(flags);
48 } 48 }
49 return flags; 49 return flags;
50 } 50 }
51} 51}