summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/bytecode/accessors
diff options
context:
space:
mode:
authorGravatar jeff2015-01-13 23:25:04 -0500
committerGravatar jeff2015-01-13 23:25:04 -0500
commit959cb5fd4f9586ec3bd265b452fe25fe1db82e3f (patch)
treebdd8a2c52c2fe053ba3460614bde8542e5378dbe /src/cuchaz/enigma/bytecode/accessors
parentgot rid of gradle in favor of ivy+ssjb (diff)
downloadenigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.gz
enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.xz
enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.zip
source format change
don't hate me too much if you were planning a big merge. =P
Diffstat (limited to 'src/cuchaz/enigma/bytecode/accessors')
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/ClassInfoAccessor.java58
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java181
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/InvokeDynamicInfoAccessor.java90
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/MemberRefInfoAccessor.java90
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/MethodHandleInfoAccessor.java90
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/MethodTypeInfoAccessor.java58
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/NameAndTypeInfoAccessor.java90
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java58
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/Utf8InfoAccessor.java23
9 files changed, 280 insertions, 458 deletions
diff --git a/src/cuchaz/enigma/bytecode/accessors/ClassInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/ClassInfoAccessor.java
index 41e1d04..d76f056 100644
--- a/src/cuchaz/enigma/bytecode/accessors/ClassInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/ClassInfoAccessor.java
@@ -12,58 +12,44 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class ClassInfoAccessor 15public class ClassInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_nameIndex; 18 private static Field m_nameIndex;
19 19
20 static 20 static {
21 { 21 try {
22 try 22 m_class = Class.forName("javassist.bytecode.ClassInfo");
23 { 23 m_nameIndex = m_class.getDeclaredField("name");
24 m_class = Class.forName( "javassist.bytecode.ClassInfo" ); 24 m_nameIndex.setAccessible(true);
25 m_nameIndex = m_class.getDeclaredField( "name" ); 25 } catch (Exception ex) {
26 m_nameIndex.setAccessible( true ); 26 throw new Error(ex);
27 }
28 catch( Exception ex )
29 {
30 throw new Error( ex );
31 } 27 }
32 } 28 }
33 29
34 public static boolean isType( ConstInfoAccessor accessor ) 30 public static boolean isType(ConstInfoAccessor accessor) {
35 { 31 return m_class.isAssignableFrom(accessor.getItem().getClass());
36 return m_class.isAssignableFrom( accessor.getItem().getClass() );
37 } 32 }
38 33
39 private Object m_item; 34 private Object m_item;
40 35
41 public ClassInfoAccessor( Object item ) 36 public ClassInfoAccessor(Object item) {
42 {
43 m_item = item; 37 m_item = item;
44 } 38 }
45 39
46 public int getNameIndex( ) 40 public int getNameIndex() {
47 { 41 try {
48 try 42 return (Integer)m_nameIndex.get(m_item);
49 { 43 } catch (Exception ex) {
50 return (Integer)m_nameIndex.get( m_item ); 44 throw new Error(ex);
51 }
52 catch( Exception ex )
53 {
54 throw new Error( ex );
55 } 45 }
56 } 46 }
57 47
58 public void setNameIndex( int val ) 48 public void setNameIndex(int val) {
59 { 49 try {
60 try 50 m_nameIndex.set(m_item, val);
61 { 51 } catch (Exception ex) {
62 m_nameIndex.set( m_item, val ); 52 throw new Error(ex);
63 }
64 catch( Exception ex )
65 {
66 throw new Error( ex );
67 } 53 }
68 } 54 }
69} 55}
diff --git a/src/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java
index 3c3d3fa..d00c102 100644
--- a/src/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/ConstInfoAccessor.java
@@ -22,44 +22,35 @@ import java.lang.reflect.Method;
22 22
23import cuchaz.enigma.bytecode.InfoType; 23import cuchaz.enigma.bytecode.InfoType;
24 24
25public class ConstInfoAccessor 25public class ConstInfoAccessor {
26{ 26
27 private static Class<?> m_class; 27 private static Class<?> m_class;
28 private static Field m_index; 28 private static Field m_index;
29 private static Method m_getTag; 29 private static Method m_getTag;
30 30
31 static 31 static {
32 { 32 try {
33 try 33 m_class = Class.forName("javassist.bytecode.ConstInfo");
34 { 34 m_index = m_class.getDeclaredField("index");
35 m_class = Class.forName( "javassist.bytecode.ConstInfo" ); 35 m_index.setAccessible(true);
36 m_index = m_class.getDeclaredField( "index" ); 36 m_getTag = m_class.getMethod("getTag");
37 m_index.setAccessible( true ); 37 m_getTag.setAccessible(true);
38 m_getTag = m_class.getMethod( "getTag" ); 38 } catch (Exception ex) {
39 m_getTag.setAccessible( true ); 39 throw new Error(ex);
40 }
41 catch( Exception ex )
42 {
43 throw new Error( ex );
44 } 40 }
45 } 41 }
46 42
47 private Object m_item; 43 private Object m_item;
48 44
49 public ConstInfoAccessor( Object item ) 45 public ConstInfoAccessor(Object item) {
50 { 46 if (item == null) {
51 if( item == null ) 47 throw new IllegalArgumentException("item cannot be null!");
52 {
53 throw new IllegalArgumentException( "item cannot be null!" );
54 } 48 }
55 m_item = item; 49 m_item = item;
56 } 50 }
57 51
58 public ConstInfoAccessor( DataInputStream in ) 52 public ConstInfoAccessor(DataInputStream in) throws IOException {
59 throws IOException 53 try {
60 {
61 try
62 {
63 // read the entry 54 // read the entry
64 String className = in.readUTF(); 55 String className = in.readUTF();
65 int oldIndex = in.readInt(); 56 int oldIndex = in.readInt();
@@ -68,132 +59,98 @@ public class ConstInfoAccessor
68 // so we have to read it here 59 // so we have to read it here
69 in.readByte(); 60 in.readByte();
70 61
71 Constructor<?> constructor = Class.forName( className ).getConstructor( DataInputStream.class, int.class ); 62 Constructor<?> constructor = Class.forName(className).getConstructor(DataInputStream.class, int.class);
72 constructor.setAccessible( true ); 63 constructor.setAccessible(true);
73 m_item = constructor.newInstance( in, oldIndex ); 64 m_item = constructor.newInstance(in, oldIndex);
74 } 65 } catch (IOException ex) {
75 catch( IOException ex )
76 {
77 throw ex; 66 throw ex;
78 } 67 } catch (Exception ex) {
79 catch( Exception ex ) 68 throw new Error(ex);
80 {
81 throw new Error( ex );
82 } 69 }
83 } 70 }
84 71
85 public Object getItem( ) 72 public Object getItem() {
86 {
87 return m_item; 73 return m_item;
88 } 74 }
89 75
90 public int getIndex( ) 76 public int getIndex() {
91 { 77 try {
92 try 78 return (Integer)m_index.get(m_item);
93 { 79 } catch (Exception ex) {
94 return (Integer)m_index.get( m_item ); 80 throw new Error(ex);
95 }
96 catch( Exception ex )
97 {
98 throw new Error( ex );
99 } 81 }
100 } 82 }
101 83
102 public void setIndex( int val ) 84 public void setIndex(int val) {
103 { 85 try {
104 try 86 m_index.set(m_item, val);
105 { 87 } catch (Exception ex) {
106 m_index.set( m_item, val ); 88 throw new Error(ex);
107 }
108 catch( Exception ex )
109 {
110 throw new Error( ex );
111 } 89 }
112 } 90 }
113 91
114 public int getTag( ) 92 public int getTag() {
115 { 93 try {
116 try 94 return (Integer)m_getTag.invoke(m_item);
117 { 95 } catch (Exception ex) {
118 return (Integer)m_getTag.invoke( m_item ); 96 throw new Error(ex);
119 }
120 catch( Exception ex )
121 {
122 throw new Error( ex );
123 } 97 }
124 } 98 }
125 99
126 public ConstInfoAccessor copy( ) 100 public ConstInfoAccessor copy() {
127 { 101 return new ConstInfoAccessor(copyItem());
128 return new ConstInfoAccessor( copyItem() );
129 } 102 }
130 103
131 public Object copyItem( ) 104 public Object copyItem() {
132 {
133 // I don't know of a simpler way to copy one of these silly things... 105 // I don't know of a simpler way to copy one of these silly things...
134 try 106 try {
135 {
136 // serialize the item 107 // serialize the item
137 ByteArrayOutputStream buf = new ByteArrayOutputStream(); 108 ByteArrayOutputStream buf = new ByteArrayOutputStream();
138 DataOutputStream out = new DataOutputStream( buf ); 109 DataOutputStream out = new DataOutputStream(buf);
139 write( out ); 110 write(out);
140 111
141 // deserialize the item 112 // deserialize the item
142 DataInputStream in = new DataInputStream( new ByteArrayInputStream( buf.toByteArray() ) ); 113 DataInputStream in = new DataInputStream(new ByteArrayInputStream(buf.toByteArray()));
143 Object item = new ConstInfoAccessor( in ).getItem(); 114 Object item = new ConstInfoAccessor(in).getItem();
144 in.close(); 115 in.close();
145 116
146 return item; 117 return item;
147 } 118 } catch (Exception ex) {
148 catch( Exception ex ) 119 throw new Error(ex);
149 {
150 throw new Error( ex );
151 } 120 }
152 } 121 }
153 122
154 public void write( DataOutputStream out ) 123 public void write(DataOutputStream out) throws IOException {
155 throws IOException 124 try {
156 { 125 out.writeUTF(m_item.getClass().getName());
157 try 126 out.writeInt(getIndex());
158 {
159 out.writeUTF( m_item.getClass().getName() );
160 out.writeInt( getIndex() );
161 127
162 Method method = m_item.getClass().getMethod( "write", DataOutputStream.class ); 128 Method method = m_item.getClass().getMethod("write", DataOutputStream.class);
163 method.setAccessible( true ); 129 method.setAccessible(true);
164 method.invoke( m_item, out ); 130 method.invoke(m_item, out);
165 } 131 } catch (IOException ex) {
166 catch( IOException ex )
167 {
168 throw ex; 132 throw ex;
169 } 133 } catch (Exception ex) {
170 catch( Exception ex ) 134 throw new Error(ex);
171 {
172 throw new Error( ex );
173 } 135 }
174 } 136 }
175 137
176 @Override 138 @Override
177 public String toString( ) 139 public String toString() {
178 { 140 try {
179 try
180 {
181 ByteArrayOutputStream buf = new ByteArrayOutputStream(); 141 ByteArrayOutputStream buf = new ByteArrayOutputStream();
182 PrintWriter out = new PrintWriter( buf ); 142 PrintWriter out = new PrintWriter(buf);
183 Method print = m_item.getClass().getMethod( "print", PrintWriter.class ); 143 Method print = m_item.getClass().getMethod("print", PrintWriter.class);
184 print.setAccessible( true ); 144 print.setAccessible(true);
185 print.invoke( m_item, out ); 145 print.invoke(m_item, out);
186 out.close(); 146 out.close();
187 return buf.toString().replace( "\n", "" ); 147 return buf.toString().replace("\n", "");
188 } 148 } catch (Exception ex) {
189 catch( Exception ex ) 149 throw new Error(ex);
190 {
191 throw new Error( ex );
192 } 150 }
193 } 151 }
194 152
195 public InfoType getType( ) 153 public InfoType getType() {
196 { 154 return InfoType.getByTag(getTag());
197 return InfoType.getByTag( getTag() );
198 } 155 }
199} 156}
diff --git a/src/cuchaz/enigma/bytecode/accessors/InvokeDynamicInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/InvokeDynamicInfoAccessor.java
index 169306a..0d780ea 100644
--- a/src/cuchaz/enigma/bytecode/accessors/InvokeDynamicInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/InvokeDynamicInfoAccessor.java
@@ -12,85 +12,63 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class InvokeDynamicInfoAccessor 15public class InvokeDynamicInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_bootstrapIndex; 18 private static Field m_bootstrapIndex;
19 private static Field m_nameAndTypeIndex; 19 private static Field m_nameAndTypeIndex;
20 20
21 static 21 static {
22 { 22 try {
23 try 23 m_class = Class.forName("javassist.bytecode.InvokeDynamicInfo");
24 { 24 m_bootstrapIndex = m_class.getDeclaredField("bootstrap");
25 m_class = Class.forName( "javassist.bytecode.InvokeDynamicInfo" ); 25 m_bootstrapIndex.setAccessible(true);
26 m_bootstrapIndex = m_class.getDeclaredField( "bootstrap" ); 26 m_nameAndTypeIndex = m_class.getDeclaredField("nameAndType");
27 m_bootstrapIndex.setAccessible( true ); 27 m_nameAndTypeIndex.setAccessible(true);
28 m_nameAndTypeIndex = m_class.getDeclaredField( "nameAndType" ); 28 } catch (Exception ex) {
29 m_nameAndTypeIndex.setAccessible( true ); 29 throw new Error(ex);
30 }
31 catch( Exception ex )
32 {
33 throw new Error( ex );
34 } 30 }
35 } 31 }
36 32
37 public static boolean isType( ConstInfoAccessor accessor ) 33 public static boolean isType(ConstInfoAccessor accessor) {
38 { 34 return m_class.isAssignableFrom(accessor.getItem().getClass());
39 return m_class.isAssignableFrom( accessor.getItem().getClass() );
40 } 35 }
41 36
42 private Object m_item; 37 private Object m_item;
43 38
44 public InvokeDynamicInfoAccessor( Object item ) 39 public InvokeDynamicInfoAccessor(Object item) {
45 {
46 m_item = item; 40 m_item = item;
47 } 41 }
48 42
49 public int getBootstrapIndex( ) 43 public int getBootstrapIndex() {
50 { 44 try {
51 try 45 return (Integer)m_bootstrapIndex.get(m_item);
52 { 46 } catch (Exception ex) {
53 return (Integer)m_bootstrapIndex.get( m_item ); 47 throw new Error(ex);
54 }
55 catch( Exception ex )
56 {
57 throw new Error( ex );
58 } 48 }
59 } 49 }
60 50
61 public void setBootstrapIndex( int val ) 51 public void setBootstrapIndex(int val) {
62 { 52 try {
63 try 53 m_bootstrapIndex.set(m_item, val);
64 { 54 } catch (Exception ex) {
65 m_bootstrapIndex.set( m_item, val ); 55 throw new Error(ex);
66 }
67 catch( Exception ex )
68 {
69 throw new Error( ex );
70 } 56 }
71 } 57 }
72 58
73 public int getNameAndTypeIndex( ) 59 public int getNameAndTypeIndex() {
74 { 60 try {
75 try 61 return (Integer)m_nameAndTypeIndex.get(m_item);
76 { 62 } catch (Exception ex) {
77 return (Integer)m_nameAndTypeIndex.get( m_item ); 63 throw new Error(ex);
78 }
79 catch( Exception ex )
80 {
81 throw new Error( ex );
82 } 64 }
83 } 65 }
84 66
85 public void setNameAndTypeIndex( int val ) 67 public void setNameAndTypeIndex(int val) {
86 { 68 try {
87 try 69 m_nameAndTypeIndex.set(m_item, val);
88 { 70 } catch (Exception ex) {
89 m_nameAndTypeIndex.set( m_item, val ); 71 throw new Error(ex);
90 }
91 catch( Exception ex )
92 {
93 throw new Error( ex );
94 } 72 }
95 } 73 }
96} 74}
diff --git a/src/cuchaz/enigma/bytecode/accessors/MemberRefInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/MemberRefInfoAccessor.java
index 2ee3aff..9fe945f 100644
--- a/src/cuchaz/enigma/bytecode/accessors/MemberRefInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/MemberRefInfoAccessor.java
@@ -12,85 +12,63 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class MemberRefInfoAccessor 15public class MemberRefInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_classIndex; 18 private static Field m_classIndex;
19 private static Field m_nameAndTypeIndex; 19 private static Field m_nameAndTypeIndex;
20 20
21 static 21 static {
22 { 22 try {
23 try 23 m_class = Class.forName("javassist.bytecode.MemberrefInfo");
24 { 24 m_classIndex = m_class.getDeclaredField("classIndex");
25 m_class = Class.forName( "javassist.bytecode.MemberrefInfo" ); 25 m_classIndex.setAccessible(true);
26 m_classIndex = m_class.getDeclaredField( "classIndex" ); 26 m_nameAndTypeIndex = m_class.getDeclaredField("nameAndTypeIndex");
27 m_classIndex.setAccessible( true ); 27 m_nameAndTypeIndex.setAccessible(true);
28 m_nameAndTypeIndex = m_class.getDeclaredField( "nameAndTypeIndex" ); 28 } catch (Exception ex) {
29 m_nameAndTypeIndex.setAccessible( true ); 29 throw new Error(ex);
30 }
31 catch( Exception ex )
32 {
33 throw new Error( ex );
34 } 30 }
35 } 31 }
36 32
37 public static boolean isType( ConstInfoAccessor accessor ) 33 public static boolean isType(ConstInfoAccessor accessor) {
38 { 34 return m_class.isAssignableFrom(accessor.getItem().getClass());
39 return m_class.isAssignableFrom( accessor.getItem().getClass() );
40 } 35 }
41 36
42 private Object m_item; 37 private Object m_item;
43 38
44 public MemberRefInfoAccessor( Object item ) 39 public MemberRefInfoAccessor(Object item) {
45 {
46 m_item = item; 40 m_item = item;
47 } 41 }
48 42
49 public int getClassIndex( ) 43 public int getClassIndex() {
50 { 44 try {
51 try 45 return (Integer)m_classIndex.get(m_item);
52 { 46 } catch (Exception ex) {
53 return (Integer)m_classIndex.get( m_item ); 47 throw new Error(ex);
54 }
55 catch( Exception ex )
56 {
57 throw new Error( ex );
58 } 48 }
59 } 49 }
60 50
61 public void setClassIndex( int val ) 51 public void setClassIndex(int val) {
62 { 52 try {
63 try 53 m_classIndex.set(m_item, val);
64 { 54 } catch (Exception ex) {
65 m_classIndex.set( m_item, val ); 55 throw new Error(ex);
66 }
67 catch( Exception ex )
68 {
69 throw new Error( ex );
70 } 56 }
71 } 57 }
72 58
73 public int getNameAndTypeIndex( ) 59 public int getNameAndTypeIndex() {
74 { 60 try {
75 try 61 return (Integer)m_nameAndTypeIndex.get(m_item);
76 { 62 } catch (Exception ex) {
77 return (Integer)m_nameAndTypeIndex.get( m_item ); 63 throw new Error(ex);
78 }
79 catch( Exception ex )
80 {
81 throw new Error( ex );
82 } 64 }
83 } 65 }
84 66
85 public void setNameAndTypeIndex( int val ) 67 public void setNameAndTypeIndex(int val) {
86 { 68 try {
87 try 69 m_nameAndTypeIndex.set(m_item, val);
88 { 70 } catch (Exception ex) {
89 m_nameAndTypeIndex.set( m_item, val ); 71 throw new Error(ex);
90 }
91 catch( Exception ex )
92 {
93 throw new Error( ex );
94 } 72 }
95 } 73 }
96} 74}
diff --git a/src/cuchaz/enigma/bytecode/accessors/MethodHandleInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/MethodHandleInfoAccessor.java
index 27b7aee..4c95b22 100644
--- a/src/cuchaz/enigma/bytecode/accessors/MethodHandleInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/MethodHandleInfoAccessor.java
@@ -12,85 +12,63 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class MethodHandleInfoAccessor 15public class MethodHandleInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_kindIndex; 18 private static Field m_kindIndex;
19 private static Field m_indexIndex; 19 private static Field m_indexIndex;
20 20
21 static 21 static {
22 { 22 try {
23 try 23 m_class = Class.forName("javassist.bytecode.MethodHandleInfo");
24 { 24 m_kindIndex = m_class.getDeclaredField("refKind");
25 m_class = Class.forName( "javassist.bytecode.MethodHandleInfo" ); 25 m_kindIndex.setAccessible(true);
26 m_kindIndex = m_class.getDeclaredField( "refKind" ); 26 m_indexIndex = m_class.getDeclaredField("refIndex");
27 m_kindIndex.setAccessible( true ); 27 m_indexIndex.setAccessible(true);
28 m_indexIndex = m_class.getDeclaredField( "refIndex" ); 28 } catch (Exception ex) {
29 m_indexIndex.setAccessible( true ); 29 throw new Error(ex);
30 }
31 catch( Exception ex )
32 {
33 throw new Error( ex );
34 } 30 }
35 } 31 }
36 32
37 public static boolean isType( ConstInfoAccessor accessor ) 33 public static boolean isType(ConstInfoAccessor accessor) {
38 { 34 return m_class.isAssignableFrom(accessor.getItem().getClass());
39 return m_class.isAssignableFrom( accessor.getItem().getClass() );
40 } 35 }
41 36
42 private Object m_item; 37 private Object m_item;
43 38
44 public MethodHandleInfoAccessor( Object item ) 39 public MethodHandleInfoAccessor(Object item) {
45 {
46 m_item = item; 40 m_item = item;
47 } 41 }
48 42
49 public int getTypeIndex( ) 43 public int getTypeIndex() {
50 { 44 try {
51 try 45 return (Integer)m_kindIndex.get(m_item);
52 { 46 } catch (Exception ex) {
53 return (Integer)m_kindIndex.get( m_item ); 47 throw new Error(ex);
54 }
55 catch( Exception ex )
56 {
57 throw new Error( ex );
58 } 48 }
59 } 49 }
60 50
61 public void setTypeIndex( int val ) 51 public void setTypeIndex(int val) {
62 { 52 try {
63 try 53 m_kindIndex.set(m_item, val);
64 { 54 } catch (Exception ex) {
65 m_kindIndex.set( m_item, val ); 55 throw new Error(ex);
66 }
67 catch( Exception ex )
68 {
69 throw new Error( ex );
70 } 56 }
71 } 57 }
72 58
73 public int getMethodRefIndex( ) 59 public int getMethodRefIndex() {
74 { 60 try {
75 try 61 return (Integer)m_indexIndex.get(m_item);
76 { 62 } catch (Exception ex) {
77 return (Integer)m_indexIndex.get( m_item ); 63 throw new Error(ex);
78 }
79 catch( Exception ex )
80 {
81 throw new Error( ex );
82 } 64 }
83 } 65 }
84 66
85 public void setMethodRefIndex( int val ) 67 public void setMethodRefIndex(int val) {
86 { 68 try {
87 try 69 m_indexIndex.set(m_item, val);
88 { 70 } catch (Exception ex) {
89 m_indexIndex.set( m_item, val ); 71 throw new Error(ex);
90 }
91 catch( Exception ex )
92 {
93 throw new Error( ex );
94 } 72 }
95 } 73 }
96} 74}
diff --git a/src/cuchaz/enigma/bytecode/accessors/MethodTypeInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/MethodTypeInfoAccessor.java
index 4cba6a2..e151117 100644
--- a/src/cuchaz/enigma/bytecode/accessors/MethodTypeInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/MethodTypeInfoAccessor.java
@@ -12,58 +12,44 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class MethodTypeInfoAccessor 15public class MethodTypeInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_descriptorIndex; 18 private static Field m_descriptorIndex;
19 19
20 static 20 static {
21 { 21 try {
22 try 22 m_class = Class.forName("javassist.bytecode.MethodTypeInfo");
23 { 23 m_descriptorIndex = m_class.getDeclaredField("descriptor");
24 m_class = Class.forName( "javassist.bytecode.MethodTypeInfo" ); 24 m_descriptorIndex.setAccessible(true);
25 m_descriptorIndex = m_class.getDeclaredField( "descriptor" ); 25 } catch (Exception ex) {
26 m_descriptorIndex.setAccessible( true ); 26 throw new Error(ex);
27 }
28 catch( Exception ex )
29 {
30 throw new Error( ex );
31 } 27 }
32 } 28 }
33 29
34 public static boolean isType( ConstInfoAccessor accessor ) 30 public static boolean isType(ConstInfoAccessor accessor) {
35 { 31 return m_class.isAssignableFrom(accessor.getItem().getClass());
36 return m_class.isAssignableFrom( accessor.getItem().getClass() );
37 } 32 }
38 33
39 private Object m_item; 34 private Object m_item;
40 35
41 public MethodTypeInfoAccessor( Object item ) 36 public MethodTypeInfoAccessor(Object item) {
42 {
43 m_item = item; 37 m_item = item;
44 } 38 }
45 39
46 public int getTypeIndex( ) 40 public int getTypeIndex() {
47 { 41 try {
48 try 42 return (Integer)m_descriptorIndex.get(m_item);
49 { 43 } catch (Exception ex) {
50 return (Integer)m_descriptorIndex.get( m_item ); 44 throw new Error(ex);
51 }
52 catch( Exception ex )
53 {
54 throw new Error( ex );
55 } 45 }
56 } 46 }
57 47
58 public void setTypeIndex( int val ) 48 public void setTypeIndex(int val) {
59 { 49 try {
60 try 50 m_descriptorIndex.set(m_item, val);
61 { 51 } catch (Exception ex) {
62 m_descriptorIndex.set( m_item, val ); 52 throw new Error(ex);
63 }
64 catch( Exception ex )
65 {
66 throw new Error( ex );
67 } 53 }
68 } 54 }
69} 55}
diff --git a/src/cuchaz/enigma/bytecode/accessors/NameAndTypeInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/NameAndTypeInfoAccessor.java
index 03b4de3..6e82f3e 100644
--- a/src/cuchaz/enigma/bytecode/accessors/NameAndTypeInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/NameAndTypeInfoAccessor.java
@@ -12,85 +12,63 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class NameAndTypeInfoAccessor 15public class NameAndTypeInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_nameIndex; 18 private static Field m_nameIndex;
19 private static Field m_typeIndex; 19 private static Field m_typeIndex;
20 20
21 static 21 static {
22 { 22 try {
23 try 23 m_class = Class.forName("javassist.bytecode.NameAndTypeInfo");
24 { 24 m_nameIndex = m_class.getDeclaredField("memberName");
25 m_class = Class.forName( "javassist.bytecode.NameAndTypeInfo" ); 25 m_nameIndex.setAccessible(true);
26 m_nameIndex = m_class.getDeclaredField( "memberName" ); 26 m_typeIndex = m_class.getDeclaredField("typeDescriptor");
27 m_nameIndex.setAccessible( true ); 27 m_typeIndex.setAccessible(true);
28 m_typeIndex = m_class.getDeclaredField( "typeDescriptor" ); 28 } catch (Exception ex) {
29 m_typeIndex.setAccessible( true ); 29 throw new Error(ex);
30 }
31 catch( Exception ex )
32 {
33 throw new Error( ex );
34 } 30 }
35 } 31 }
36 32
37 public static boolean isType( ConstInfoAccessor accessor ) 33 public static boolean isType(ConstInfoAccessor accessor) {
38 { 34 return m_class.isAssignableFrom(accessor.getItem().getClass());
39 return m_class.isAssignableFrom( accessor.getItem().getClass() );
40 } 35 }
41 36
42 private Object m_item; 37 private Object m_item;
43 38
44 public NameAndTypeInfoAccessor( Object item ) 39 public NameAndTypeInfoAccessor(Object item) {
45 {
46 m_item = item; 40 m_item = item;
47 } 41 }
48 42
49 public int getNameIndex( ) 43 public int getNameIndex() {
50 { 44 try {
51 try 45 return (Integer)m_nameIndex.get(m_item);
52 { 46 } catch (Exception ex) {
53 return (Integer)m_nameIndex.get( m_item ); 47 throw new Error(ex);
54 }
55 catch( Exception ex )
56 {
57 throw new Error( ex );
58 } 48 }
59 } 49 }
60 50
61 public void setNameIndex( int val ) 51 public void setNameIndex(int val) {
62 { 52 try {
63 try 53 m_nameIndex.set(m_item, val);
64 { 54 } catch (Exception ex) {
65 m_nameIndex.set( m_item, val ); 55 throw new Error(ex);
66 }
67 catch( Exception ex )
68 {
69 throw new Error( ex );
70 } 56 }
71 } 57 }
72 58
73 public int getTypeIndex( ) 59 public int getTypeIndex() {
74 { 60 try {
75 try 61 return (Integer)m_typeIndex.get(m_item);
76 { 62 } catch (Exception ex) {
77 return (Integer)m_typeIndex.get( m_item ); 63 throw new Error(ex);
78 }
79 catch( Exception ex )
80 {
81 throw new Error( ex );
82 } 64 }
83 } 65 }
84 66
85 public void setTypeIndex( int val ) 67 public void setTypeIndex(int val) {
86 { 68 try {
87 try 69 m_typeIndex.set(m_item, val);
88 { 70 } catch (Exception ex) {
89 m_typeIndex.set( m_item, val ); 71 throw new Error(ex);
90 }
91 catch( Exception ex )
92 {
93 throw new Error( ex );
94 } 72 }
95 } 73 }
96} 74}
diff --git a/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java
index 5cdfce4..6665ffe 100644
--- a/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java
@@ -12,58 +12,44 @@ package cuchaz.enigma.bytecode.accessors;
12 12
13import java.lang.reflect.Field; 13import java.lang.reflect.Field;
14 14
15public class StringInfoAccessor 15public class StringInfoAccessor {
16{ 16
17 private static Class<?> m_class; 17 private static Class<?> m_class;
18 private static Field m_stringIndex; 18 private static Field m_stringIndex;
19 19
20 static 20 static {
21 { 21 try {
22 try 22 m_class = Class.forName("javassist.bytecode.StringInfo");
23 { 23 m_stringIndex = m_class.getDeclaredField("string");
24 m_class = Class.forName( "javassist.bytecode.StringInfo" ); 24 m_stringIndex.setAccessible(true);
25 m_stringIndex = m_class.getDeclaredField( "string" ); 25 } catch (Exception ex) {
26 m_stringIndex.setAccessible( true ); 26 throw new Error(ex);
27 }
28 catch( Exception ex )
29 {
30 throw new Error( ex );
31 } 27 }
32 } 28 }
33 29
34 public static boolean isType( ConstInfoAccessor accessor ) 30 public static boolean isType(ConstInfoAccessor accessor) {
35 { 31 return m_class.isAssignableFrom(accessor.getItem().getClass());
36 return m_class.isAssignableFrom( accessor.getItem().getClass() );
37 } 32 }
38 33
39 private Object m_item; 34 private Object m_item;
40 35
41 public StringInfoAccessor( Object item ) 36 public StringInfoAccessor(Object item) {
42 {
43 m_item = item; 37 m_item = item;
44 } 38 }
45 39
46 public int getStringIndex( ) 40 public int getStringIndex() {
47 { 41 try {
48 try 42 return (Integer)m_stringIndex.get(m_item);
49 { 43 } catch (Exception ex) {
50 return (Integer)m_stringIndex.get( m_item ); 44 throw new Error(ex);
51 }
52 catch( Exception ex )
53 {
54 throw new Error( ex );
55 } 45 }
56 } 46 }
57 47
58 public void setStringIndex( int val ) 48 public void setStringIndex(int val) {
59 { 49 try {
60 try 50 m_stringIndex.set(m_item, val);
61 { 51 } catch (Exception ex) {
62 m_stringIndex.set( m_item, val ); 52 throw new Error(ex);
63 }
64 catch( Exception ex )
65 {
66 throw new Error( ex );
67 } 53 }
68 } 54 }
69} 55}
diff --git a/src/cuchaz/enigma/bytecode/accessors/Utf8InfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/Utf8InfoAccessor.java
index 1cadd83..2abf60b 100644
--- a/src/cuchaz/enigma/bytecode/accessors/Utf8InfoAccessor.java
+++ b/src/cuchaz/enigma/bytecode/accessors/Utf8InfoAccessor.java
@@ -10,24 +10,19 @@
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.bytecode.accessors; 11package cuchaz.enigma.bytecode.accessors;
12 12
13public class Utf8InfoAccessor 13public class Utf8InfoAccessor {
14{ 14
15 private static Class<?> m_class; 15 private static Class<?> m_class;
16 16
17 static 17 static {
18 { 18 try {
19 try 19 m_class = Class.forName("javassist.bytecode.Utf8Info");
20 { 20 } catch (Exception ex) {
21 m_class = Class.forName( "javassist.bytecode.Utf8Info" ); 21 throw new Error(ex);
22 }
23 catch( Exception ex )
24 {
25 throw new Error( ex );
26 } 22 }
27 } 23 }
28 24
29 public static boolean isType( ConstInfoAccessor accessor ) 25 public static boolean isType(ConstInfoAccessor accessor) {
30 { 26 return m_class.isAssignableFrom(accessor.getItem().getClass());
31 return m_class.isAssignableFrom( accessor.getItem().getClass() );
32 } 27 }
33} 28}