summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java')
-rw-r--r--src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java58
1 files changed, 22 insertions, 36 deletions
diff --git a/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java b/src/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java
index 5cdfce4d..6665ffe4 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}