/** * Remove a cached class. */ private boolean removeFromCache(String name, BCClass bc) { BCClass rem = (BCClass) checkCache(name); if (rem != bc) return false; _cache.remove(name); return true; } }
/** * Remove a cached class. */ private boolean removeFromCache(String name, BCClass bc) { BCClass rem = (BCClass) checkCache(name); if (rem != bc) return false; _cache.remove(name); return true; } }
/** * Remove a class from this project. After removal, the result of any * further operations on the class is undefined. * * @return true if the class belonged to this project, false otherwise */ public boolean removeClass(Class type) { if (type == null) return false; return removeClass(checkCache(type.getName())); }
/** * Remove a class from this project. After removal, the result of any * further operations on the class is undefined. * * @return true if the class belonged to this project, false otherwise */ public boolean removeClass(Class type) { if (type == null) return false; return removeClass(checkCache(type.getName())); }
/** * Remove a class from this project. After removal, the result of any * further operations on the class is undefined. * * @return true if the class belonged to this project, false otherwise */ public boolean removeClass(String type) { return removeClass(checkCache(type)); }
/** * Remove a class from this project. After removal, the result of any * further operations on the class is undefined. * * @return true if the class belonged to this project, false otherwise */ public boolean removeClass(String type) { return removeClass(checkCache(type)); }
/** * Renames the given class within this project. Used internally by * {@link BCClass} instances when their name is modified. * * @throws IllegalStateException if a class with the new name already exists */ void renameClass(String oldName, String newName, BCClass bc) { if (oldName.equals(newName)) return; BCClass cached = (BCClass) checkCache(newName); if (cached != null) throw new IllegalStateException("A class with name " + newName + " already exists in this project"); removeFromCache(oldName, bc); cache(newName, bc); }
/** * Renames the given class within this project. Used internally by * {@link BCClass} instances when their name is modified. * * @throws IllegalStateException if a class with the new name already exists */ void renameClass(String oldName, String newName, BCClass bc) { if (oldName.equals(newName)) return; BCClass cached = (BCClass) checkCache(newName); if (cached != null) throw new IllegalStateException("A class with name " + newName + " already exists in this project"); removeFromCache(oldName, bc); cache(newName, bc); }
BCClass cached = checkCache(type.getName()); if (cached != null) return cached;
/** * 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; }
BCClass cached = checkCache(type.getName()); if (cached != null) return cached;
/** * 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 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; }
BCClass cached = checkCache(name); if (cached != null) return cached;
BCClass cached = checkCache(name); if (cached != null) return cached;
/** * 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; }