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