/** * Initialize from the class definition in the given file. For use by * the owning project only. */ void read(File classFile, ClassLoader loader) throws IOException { InputStream in = new FileInputStream(classFile); try { read(in, loader); } finally { in.close(); } }
/** * Initialize from the class definition in the given file. For use by * the owning project only. */ void read(File classFile, ClassLoader loader) throws IOException { InputStream in = new FileInputStream(classFile); try { read(in, loader); } finally { in.close(); } }
/** * Initialize from the bytecode of the definition of the given class. * For use by the owning project only. */ void read(Class type) throws IOException { // find out the length of the package name int dotIndex = type.getName().lastIndexOf('.') + 1; // strip the package off of the class name String className = type.getName().substring(dotIndex); // attempt to get the class file for the class as a stream InputStream in = type.getResourceAsStream(className + ".class"); try { read(in, type.getClassLoader()); } finally { in.close(); } }
/** * Initialize from the bytecode of the definition of the given class. * For use by the owning project only. */ void read(Class type) throws IOException { // find out the length of the package name int dotIndex = type.getName().lastIndexOf('.') + 1; // strip the package off of the class name String className = type.getName().substring(dotIndex); // attempt to get the class file for the class as a stream InputStream in = type.getResourceAsStream(className + ".class"); try { read(in, type.getClassLoader()); } finally { in.close(); } }
/** * Initialize from the given parsed bytecode. * For use by the owning project only. */ void read(BCClass orig) { try { ByteArrayInputStream in = new ByteArrayInputStream (orig.toByteArray()); read(in, orig.getClassLoader()); in.close(); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } }
/** * Initialize from the given parsed bytecode. * For use by the owning project only. */ void read(BCClass orig) { try { ByteArrayInputStream in = new ByteArrayInputStream (orig.toByteArray()); read(in, orig.getClassLoader()); in.close(); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } }
ret.setState(new ObjectState(_names)); try { ret.read(type); } catch (IOException ioe) { throw new RuntimeException(ioe.toString());
ret.setState(new ObjectState(_names)); try { ret.read(type); } catch (IOException ioe) { throw new RuntimeException(ioe.toString());
/** * Load the bytecode from the given class file. * If this project already contains the class in the given file, it will * be returned. Otherwise a new {@link BCClass} will be created from the * given bytecode. * * @throws RuntimeException on parse error */ public BCClass loadClass(File classFile, ClassLoader loader) { // parse the bytecode from the file BCClass ret = new BCClass(this); ret.setState(new ObjectState(_names)); try { ret.read(classFile, loader); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } String name = ret.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; cache(name, ret); return ret; }
/** * Load the bytecode from the given stream. * If this project already contains the class in the given stream, * it will be returned. Otherwise a new {@link BCClass} will be created * from the given bytecode. * * @throws RuntimeException on parse error */ public BCClass loadClass(InputStream in, ClassLoader loader) { BCClass ret = new BCClass(this); ret.setState(new ObjectState(_names)); try { ret.read(in, loader); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } String name = ret.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; cache(name, ret); return ret; }
/** * Load the bytecode from the given stream. * If this project already contains the class in the given stream, * it will be returned. Otherwise a new {@link BCClass} will be created * from the given bytecode. * * @throws RuntimeException on parse error */ public BCClass loadClass(InputStream in, ClassLoader loader) { BCClass ret = new BCClass(this); ret.setState(new ObjectState(_names)); try { ret.read(in, loader); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } String name = ret.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; cache(name, ret); return ret; }
/** * Load the bytecode from the given class file. * If this project already contains the class in the given file, it will * be returned. Otherwise a new {@link BCClass} will be created from the * given bytecode. * * @throws RuntimeException on parse error */ public BCClass loadClass(File classFile, ClassLoader loader) { // parse the bytecode from the file BCClass ret = new BCClass(this); ret.setState(new ObjectState(_names)); try { ret.read(classFile, loader); } catch (IOException ioe) { throw new RuntimeException(ioe.toString()); } String name = ret.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; cache(name, ret); return ret; }
/** * Import the given bytecode from another project. If a {@link BCClass} * with the same name already exists in this project, it will be returned. * Otherwise, a new {@link BCClass} will be created from the * information in the given class. */ public BCClass loadClass(BCClass bc) { String name = bc.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; BCClass ret = new BCClass(this); if (bc.isPrimitive()) ret.setState(new PrimitiveState(bc.getType(), _names)); else if (bc.isArray()) ret.setState(new ArrayState(bc.getName(), bc.getComponentName())); else { ret.setState(new ObjectState(_names)); ret.read(bc); } cache(name, ret); return ret; }
/** * Import the given bytecode from another project. If a {@link BCClass} * with the same name already exists in this project, it will be returned. * Otherwise, a new {@link BCClass} will be created from the * information in the given class. */ public BCClass loadClass(BCClass bc) { String name = bc.getName(); BCClass cached = checkCache(name); if (cached != null) return cached; BCClass ret = new BCClass(this); if (bc.isPrimitive()) ret.setState(new PrimitiveState(bc.getType(), _names)); else if (bc.isArray()) ret.setState(new ArrayState(bc.getName(), bc.getComponentName())); else { ret.setState(new ObjectState(_names)); ret.read(bc); } cache(name, ret); return ret; }