1101 byte[] tb = new byte[len]; 1102 b.get(tb); // get bytes out of byte buffer. 1103 return defineClass(name, tb, 0, len, protectionDomain); 1104 } 1105 } 1106 1107 protectionDomain = preDefineClass(name, protectionDomain); 1108 String source = defineClassSourceLocation(protectionDomain); 1109 Class<?> c = defineClass2(this, name, b, b.position(), len, protectionDomain, source); 1110 postDefineClass(c, protectionDomain); 1111 return c; 1112 } 1113 1114 static native Class<?> defineClass1(ClassLoader loader, String name, byte[] b, int off, int len, 1115 ProtectionDomain pd, String source); 1116 1117 static native Class<?> defineClass2(ClassLoader loader, String name, java.nio.ByteBuffer b, 1118 int off, int len, ProtectionDomain pd, 1119 String source); 1120 1121 // true if the name is null or has the potential to be a valid binary name 1122 private boolean checkName(String name) { 1123 if ((name == null) || (name.isEmpty())) 1124 return true; 1125 if ((name.indexOf('/') != -1) || (name.charAt(0) == '[')) 1126 return false; 1127 return true; 1128 } 1129 1130 private void checkCerts(String name, CodeSource cs) { 1131 int i = name.lastIndexOf('.'); 1132 String pname = (i == -1) ? "" : name.substring(0, i); 1133 1134 Certificate[] certs = null; 1135 if (cs != null) { 1136 certs = cs.getCertificates(); 1137 } 1138 Certificate[] pcerts = null; 1139 if (parallelLockMap == null) { 1140 synchronized (this) { | 1101 byte[] tb = new byte[len]; 1102 b.get(tb); // get bytes out of byte buffer. 1103 return defineClass(name, tb, 0, len, protectionDomain); 1104 } 1105 } 1106 1107 protectionDomain = preDefineClass(name, protectionDomain); 1108 String source = defineClassSourceLocation(protectionDomain); 1109 Class<?> c = defineClass2(this, name, b, b.position(), len, protectionDomain, source); 1110 postDefineClass(c, protectionDomain); 1111 return c; 1112 } 1113 1114 static native Class<?> defineClass1(ClassLoader loader, String name, byte[] b, int off, int len, 1115 ProtectionDomain pd, String source); 1116 1117 static native Class<?> defineClass2(ClassLoader loader, String name, java.nio.ByteBuffer b, 1118 int off, int len, ProtectionDomain pd, 1119 String source); 1120 1121 /** 1122 * Defines a class of the given flags via Lookup.defineClass. 1123 * 1124 * @param loader the defining loader 1125 * @param lookup nest host of the Class to be defined 1126 * @param name the binary name or {@code null} if not findable 1127 * @param b class bytes 1128 * @param off the start offset in {@code b} of the class bytes 1129 * @param len the length of the class bytes 1130 * @param pd protection domain 1131 * @param initialize initialize the class 1132 * @param flags flags 1133 * @param classData class data 1134 */ 1135 static native Class<?> defineClass0(ClassLoader loader, 1136 Class<?> lookup, 1137 String name, 1138 byte[] b, int off, int len, 1139 ProtectionDomain pd, 1140 boolean initialize, 1141 int flags, 1142 Object classData); 1143 1144 // true if the name is null or has the potential to be a valid binary name 1145 private boolean checkName(String name) { 1146 if ((name == null) || (name.isEmpty())) 1147 return true; 1148 if ((name.indexOf('/') != -1) || (name.charAt(0) == '[')) 1149 return false; 1150 return true; 1151 } 1152 1153 private void checkCerts(String name, CodeSource cs) { 1154 int i = name.lastIndexOf('.'); 1155 String pname = (i == -1) ? "" : name.substring(0, i); 1156 1157 Certificate[] certs = null; 1158 if (cs != null) { 1159 certs = cs.getCertificates(); 1160 } 1161 Certificate[] pcerts = null; 1162 if (parallelLockMap == null) { 1163 synchronized (this) { |