1 7 8 package javax.management.loading; 9 10 11 13 import java.io.*; 14 import java.lang.reflect.Array ; 15 16 17 23 class MLetObjectInputStream extends ObjectInputStream { 24 25 private MLet loader; 26 27 30 public MLetObjectInputStream(InputStream in, MLet loader) 31 throws IOException, StreamCorruptedException { 32 33 super(in); 34 if (loader == null) { 35 throw new IllegalArgumentException ("Illegal null argument to MLetObjectInputStream"); 36 } 37 this.loader = loader; 38 } 39 40 private Class primitiveType(char c) { 41 switch(c) { 42 case 66: 43 return Byte.TYPE; 44 45 case 67: 46 return Character.TYPE; 47 48 case 68: 49 return Double.TYPE; 50 51 case 70: 52 return Float.TYPE; 53 54 case 73: 55 return Integer.TYPE; 56 57 case 74: 58 return Long.TYPE; 59 60 case 83: 61 return Short.TYPE; 62 63 case 90: 64 return Boolean.TYPE; 65 } 66 return null; 67 } 68 69 72 protected Class resolveClass(ObjectStreamClass objectstreamclass) 73 throws IOException, ClassNotFoundException { 74 75 String s = objectstreamclass.getName(); 76 if (s.startsWith("[")) { 77 int i; 78 for (i = 1; s.charAt(i) == '['; i++); 79 Class class1; 80 if (s.charAt(i) == 'L') { 81 class1 = loader.loadClass(s.substring(i + 1, s.length() - 1)); 82 } else { 83 if (s.length() != i + 1) 84 throw new ClassNotFoundException (s); 85 class1 = primitiveType(s.charAt(i)); 86 } 87 int ai[] = new int[i]; 88 for (int j = 0; j < i; j++) 89 ai[j] = 0; 90 91 return Array.newInstance(class1, ai).getClass(); 92 } else { 93 return loader.loadClass(s); 94 } 95 } 96 97 100 public ClassLoader getClassLoader() { 101 return loader; 102 } 103 } 104 | Popular Tags |