public static byte[] toByteArray(BCClass bc, byte[] returnBytes) throws IOException { if (bc.getMajorVersion() >= Java7_MajorVersion) { returnBytes = toJava7ByteArray(bc, returnBytes); } return returnBytes; }
public static void write(BCClass bc, File outFile) throws IOException { if (bc.getMajorVersion() < Java7_MajorVersion) { bc.write(outFile); } else { OutputStream out = new FileOutputStream(outFile); try { writeJava7(bc, out); } finally { out.flush(); out.close(); } } }
public static void debugBytecodes(BCClass bc) throws IOException { // Write the bytecodes to disk for debugging purposes. if ("true".equals(System.getProperty( ManagedClassSubclasser.class.getName() + ".dumpBytecodes"))) { File tmp = new File(System.getProperty("java.io.tmpdir")); File dir = new File(tmp, "openjpa"); dir = new File(dir, "pcsubclasses"); dir.mkdirs(); dir = Files.getPackageFile(dir, bc.getPackageName(), true); File f = new File(dir, bc.getClassName() + ".class"); // START - ALLOW PRINT STATEMENTS System.err.println("Writing to " + f); // STOP - ALLOW PRINT STATEMENTS AsmAdaptor.write(bc, f); } }
return null; BCClass pcb = enhancer.getPCBytecode(); returnBytes = AsmAdaptor.toByteArray(pcb, pcb.toByteArray()); return returnBytes; } finally {
/** * Analyze the bytecode to see if the given class definition implements * {@link PersistenceCapable}. */ private static boolean isEnhanced(byte[] b) { if (AsmAdaptor.use()) { return AsmAdaptor.isEnhanced(b); } ConstantPoolTable table = new ConstantPoolTable(b); int idx = table.getEndIndex(); idx += 6; // skip access, cls, super int ifaces = table.readUnsignedShort(idx); int clsEntry, utfEntry; String name; for (int i = 0; i < ifaces; i++) { idx += 2; clsEntry = table.readUnsignedShort(idx); utfEntry = table.readUnsignedShort(table.get(clsEntry)); name = table.readString(table.get(utfEntry)); if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name)) return true; } return false; } }
@Override public void visit(final int i, final int i1, final String name, final String s, final String parent, final String[] interfaces) { boolean enhanced = interfaces != null && interfaces.length > 0 && asList(interfaces).contains("org/apache/openjpa/enhance/PersistenceCapable"); if (!enhanced && name != null && parent != null && !"java/lang/Object".equals(parent) && !name.equals(parent)) { enhanced = isEnhanced(bytes(parent)); } throw new EnhancedStatusException(enhanced); } }, 0);
return null; BCClass pcb = enhancer.getPCBytecode(); returnBytes = AsmAdaptor.toByteArray(pcb, pcb.toByteArray()); return returnBytes; } finally {
/** * Analyze the bytecode to see if the given class definition implements * {@link PersistenceCapable}. */ private static boolean isEnhanced(byte[] b) { if (AsmAdaptor.use()) { return AsmAdaptor.isEnhanced(b); } ConstantPoolTable table = new ConstantPoolTable(b); int idx = table.getEndIndex(); idx += 6; // skip access, cls, super int ifaces = table.readUnsignedShort(idx); int clsEntry, utfEntry; String name; for (int i = 0; i < ifaces; i++) { idx += 2; clsEntry = table.readUnsignedShort(idx); utfEntry = table.readUnsignedShort(table.get(clsEntry)); name = table.readString(table.get(utfEntry)); if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name)) return true; } return false; } }
@Override public void visit(final int i, final int i1, final String name, final String s, final String parent, final String[] interfaces) { boolean enhanced = interfaces != null && interfaces.length > 0 && asList(interfaces).contains("org/apache/openjpa/enhance/PersistenceCapable"); if (!enhanced && name != null && parent != null && !"java/lang/Object".equals(parent) && !name.equals(parent)) { enhanced = isEnhanced(bytes(parent)); } throw new EnhancedStatusException(enhanced); } }, 0);
public static void debugBytecodes(BCClass bc) throws IOException { // Write the bytecodes to disk for debugging purposes. if ("true".equals(System.getProperty( ManagedClassSubclasser.class.getName() + ".dumpBytecodes"))) { File tmp = new File(System.getProperty("java.io.tmpdir")); File dir = new File(tmp, "openjpa"); dir = new File(dir, "pcsubclasses"); dir.mkdirs(); dir = Files.getPackageFile(dir, bc.getPackageName(), true); File f = new File(dir, bc.getClassName() + ".class"); // START - ALLOW PRINT STATEMENTS System.err.println("Writing to " + f); // STOP - ALLOW PRINT STATEMENTS AsmAdaptor.write(bc, f); } }
public static byte[] toByteArray(BCClass bc, byte[] returnBytes) throws IOException { if (bc.getMajorVersion() >= Java7_MajorVersion) { returnBytes = toJava7ByteArray(bc, returnBytes); } return returnBytes; }
public static void write(BCClass bc, File outFile) throws IOException { if (bc.getMajorVersion() < Java7_MajorVersion) { bc.write(outFile); } else { OutputStream out = new FileOutputStream(outFile); try { writeJava7(bc, out); } finally { out.flush(); out.close(); } } }
return null; BCClass pcb = enhancer.getPCBytecode(); returnBytes = AsmAdaptor.toByteArray(pcb, pcb.toByteArray()); return returnBytes; } catch (Throwable t) {
public static void debugBytecodes(BCClass bc) throws IOException { // Write the bytecodes to disk for debugging purposes. if ("true".equals(System.getProperty( ManagedClassSubclasser.class.getName() + ".dumpBytecodes"))) { File tmp = new File(System.getProperty("java.io.tmpdir")); File dir = new File(tmp, "openjpa"); dir = new File(dir, "pcsubclasses"); dir.mkdirs(); dir = Files.getPackageFile(dir, bc.getPackageName(), true); File f = new File(dir, bc.getClassName() + ".class"); // START - ALLOW PRINT STATEMENTS System.err.println("Writing to " + f); // STOP - ALLOW PRINT STATEMENTS AsmAdaptor.write(bc, f); } }
private static void writeJava7(BCClass bc, OutputStream out) throws IOException { byte[] java7Bytes = toJava7ByteArray(bc, bc.toByteArray()); out.write(java7Bytes); }
public static void write(BCClass bc, File outFile) throws IOException { if (bc.getMajorVersion() < Java7_MajorVersion) { bc.write(outFile); } else { OutputStream out = new FileOutputStream(outFile); try { writeJava7(bc, out); } finally { out.flush(); out.close(); } } }
return null; BCClass pcb = enhancer.getPCBytecode(); returnBytes = AsmAdaptor.toByteArray(pcb, pcb.toByteArray()); return returnBytes; } catch (Throwable t) {
public static void debugBytecodes(BCClass bc) throws IOException { // Write the bytecodes to disk for debugging purposes. if ("true".equals(System.getProperty( ManagedClassSubclasser.class.getName() + ".dumpBytecodes"))) { File tmp = new File(System.getProperty("java.io.tmpdir")); File dir = new File(tmp, "openjpa"); dir = new File(dir, "pcsubclasses"); dir.mkdirs(); dir = Files.getPackageFile(dir, bc.getPackageName(), true); File f = new File(dir, bc.getClassName() + ".class"); // START - ALLOW PRINT STATEMENTS System.err.println("Writing to " + f); // STOP - ALLOW PRINT STATEMENTS AsmAdaptor.write(bc, f); } }
public static byte[] toByteArray(BCClass bc, byte[] returnBytes) throws IOException { if (bc.getMajorVersion() >= Java7_MajorVersion) { returnBytes = toJava7ByteArray(bc, returnBytes); } return returnBytes; }
public static void write(BCClass bc, File outFile) throws IOException { if (bc.getMajorVersion() < Java7_MajorVersion) { bc.write(outFile); } else { OutputStream out = new FileOutputStream(outFile); try { writeJava7(bc, out); } finally { out.flush(); out.close(); } } }