1 11 package org.eclipse.jdi.internal; 12 13 14 import java.lang.reflect.Field ; 15 import java.lang.reflect.Modifier ; 16 17 import com.sun.jdi.Accessible; 18 19 25 public abstract class AccessibleImpl extends MirrorImpl implements Accessible { 26 27 public static final int MODIFIER_SYNTHETIC = 0xf0000000; 28 29 public static final int MODIFIER_ACC_PUBLIC = 0x0001; 30 31 public static final int MODIFIER_ACC_PRIVATE = 0x0002; 32 33 public static final int MODIFIER_ACC_PROTECTED = 0x0004; 34 35 public static final int MODIFIER_ACC_STATIC = 0x0008; 36 37 public static final int MODIFIER_ACC_FINAL = 0x0010; 38 39 public static final int MODIFIER_ACC_SYNCHRONIZED = 0x0020; 40 41 public static final int MODIFIER_ACC_SUPER = 0x0020; 42 43 public static final int MODIFIER_ACC_BRIDGE = 0x0040; 44 45 public static final int MODIFIER_ACC_VOLITILE = 0x0040; 46 47 public static final int MODIFIER_ACC_TRANSIENT = 0x0080; 48 49 public static final int MODIFIER_ACC_VARARGS = 0x0080; 50 51 public static final int MODIFIER_ACC_ENUM = 0x0100; 52 53 public static final int MODIFIER_ACC_NATIVE = 0x0100; 54 55 public static final int MODIFIER_ACC_ABSTRACT = 0x0400; 56 57 public static final int MODIFIER_ACC_STRICT = 0x0800; 58 59 public static final int MODIFIER_ACC_SYNTHETIC = 0x1000; 60 61 62 private static String [] fgModifiers = null; 63 64 67 public AccessibleImpl(String description, VirtualMachineImpl vmImpl) { 68 super(description, vmImpl); 69 } 70 71 74 public boolean isPackagePrivate() { 75 return !(isPrivate() || isPublic() || isProtected()); 76 } 77 78 81 public boolean isPrivate() { 82 return (modifiers() & MODIFIER_ACC_PRIVATE) != 0; 83 } 84 85 88 public boolean isPublic() { 89 return (modifiers() & MODIFIER_ACC_PUBLIC) != 0; 90 } 91 92 95 public boolean isProtected() { 96 return (modifiers() & MODIFIER_ACC_PROTECTED) != 0; 97 } 98 99 102 public static void getConstantMaps() { 103 if (fgModifiers != null) { 104 return; 105 } 106 107 Field [] fields = AccessibleImpl.class.getDeclaredFields(); 108 fgModifiers = new String [32]; 109 110 for (int i = 0; i < fields.length; i++) { 111 Field field = fields[i]; 112 int modifiers= field.getModifiers(); 113 if ((modifiers & Modifier.PUBLIC) == 0 || (modifiers & Modifier.STATIC) == 0 || (modifiers & Modifier.FINAL) == 0) 114 continue; 115 116 String name = field.getName(); 117 if (!name.startsWith("MODIFIER_")) { continue; 119 } 120 121 name = name.substring(9); 122 123 try { 124 int value = field.getInt(null); 125 126 for (int j = 0; j < 32; j++) { 127 if ((1 << j & value) != 0) { 128 fgModifiers[j]= name; 129 break; 130 } 131 } 132 } catch (IllegalAccessException e) { 133 } catch (IllegalArgumentException e) { 135 } 139 } 140 } 141 142 145 public static String [] getModifierStrings() { 146 getConstantMaps(); 147 return fgModifiers; 148 } 149 } 150 | Popular Tags |