public static Class<?> toClass(ClassFile ct, ClassLoader loader, ProtectionDomain domain) { if (MAGIC_IN_PROGRESS.get()) { try { final Class<?> originalProxyClass = loader.loadClass(ct.getName()); try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); ct.write(out); Map<Class<?>, byte[]> reloadMap = new HashMap<Class<?>, byte[]>(); reloadMap.put(originalProxyClass, out.getBytes()); // TODO : is this standard way how to reload class? PluginManager.getInstance().hotswap(reloadMap); return originalProxyClass; } catch (Exception e) { throw new RuntimeException(e); } } catch (ClassNotFoundException e) { //it has not actually been loaded yet return ClassFileUtils.toClass(ct, loader, domain); } } return ClassFileUtils.toClass(ct, loader, domain); }
public byte[] toBytecode() { // TODO: throw illegal state exception if the class file is modified after writing if (bytecode == null) { try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); write(out); bytecode = out.getBytes(); } catch (IOException e) { throw new RuntimeException(e); } } return bytecode; }
public byte[] toBytecode() { // TODO: throw illegal state exception if the class file is modified after writing if (bytecode == null) { try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); write(out); bytecode = out.getBytes(); } catch (IOException e) { throw new RuntimeException(e); } } return bytecode; }
public byte[] toBytecode() { // TODO: throw illegal state exception if the class file is modified after writing if (bytecode == null) { try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); write(out); bytecode = out.getBytes(); } catch (IOException e) { throw new RuntimeException(e); } } return bytecode; }
public byte[] toBytecode() { // TODO: throw illegal state exception if the class file is modified after writing if (bytecode == null) { try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); write(out); bytecode = out.getBytes(); } catch (IOException e) { throw new RuntimeException(e); } } return bytecode; }
public byte[] toBytecode() { // TODO: throw illegal state exception if the class file is modified after writing if (bytecode == null) { try { ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(); write(out); bytecode = out.getBytes(); } catch (IOException e) { throw new RuntimeException(e); } } return bytecode; }
public static Class toClass(ClassFile ct, ClassLoader loader, ProtectionDomain domain) { if (MAGIC_IN_PROGRESS.get()) { try { final Class<?> originalProxyClass = loader.loadClass(ct.getName()); try { ByteArrayDataOutputStream bs = new ByteArrayDataOutputStream(); ct.write(bs); Fakereplace.redefine(new ClassDefinition[]{new ClassDefinition(originalProxyClass, bs.getBytes())}, new AddedClass[0], false); return originalProxyClass; } catch (Exception e) { throw new RuntimeException("Failed " + ct.getName(), e); } } catch (ClassNotFoundException e) { //it has not actually been loaded yet return ClassFileUtils.toClass(ct, loader, domain); } } return ClassFileUtils.toClass(ct, loader, domain); }