static void setBody0(CtClass srcClass, MethodInfo srcInfo, CtClass destClass, MethodInfo destInfo, ClassMap map) throws CannotCompileException { destClass.checkModify(); map = new ClassMap(map); map.put(srcClass.getName(), destClass.getName()); try { CodeAttribute cattr = srcInfo.getCodeAttribute(); if (cattr != null) { ConstPool cp = destInfo.getConstPool(); CodeAttribute ca = (CodeAttribute)cattr.copy(cp, map); destInfo.setCodeAttribute(ca); // a stack map table is copied to destInfo. } } catch (CodeAttribute.RuntimeCopyException e) { /* the exception may be thrown by copy() in CodeAttribute. */ throw new CannotCompileException(e); } destInfo.setAccessFlags(destInfo.getAccessFlags() & ~AccessFlag.ABSTRACT); destClass.rebuildClassFile(); }
/** * Is equivalent to <code>put()</code> except that * the given mapping is not recorded into the hashtable * if another mapping from <code>oldname</code> is * already included. * * @param oldname the original class name. * @param newname the substituted class name. */ public void putIfNone(String oldname, String newname) { if (oldname == newname) return; String oldname2 = toJvmName(oldname); String s = (String)get(oldname2); if (s == null) super.put(oldname2, toJvmName(newname)); }
CtMethod originalMethod = method; if (method.getName().equals("getActor")) { ClassMap map = new ClassMap(); map.put(Actor.class.getName(),Actor.class.getName()); method = CtMethod.make( "public "+Actor.class.getName()+" getActor() { return __target; }", cc ) ; } else { ClassMap map = new ClassMap(); map.fix(orig); map.fix(Actor.class.getName()); method = new CtMethod(method, cc, map);
/** * Prevents a mapping from the specified class name to another name. */ public void fix(CtClass clazz) { fix(clazz.getName()); }
/** * Returns the class name to wihch the given <code>jvmClassName</code> * is mapped. A subclass of this class should override this method. * * <p>This method receives and returns the internal representation of * class name used in the JVM. * * @see #toJvmName(String) * @see #toJavaName(String) */ public Object get(Object jvmClassName) { Object found = super.get(jvmClassName); if (found == null && parent != null) return parent.get(jvmClassName); else return found; }
JdbcJavassistProxyFactory() { classMap = new ClassMap(); ClassPool defaultPool = ClassPool.getDefault(); classPool = new ClassPool(defaultPool); classPool.insertClassPath(new ClassClassPath(this.getClass())); classPool.childFirstLookup = true; createProxyConnectionClass(); createProxyStatementClass(); createProxyCallableStatementClass(); createProxyPreparedStatementClass(); createProxyResultSetClass(); lrcProxyFactory = new JdbcJavaProxyFactory(); // Clear the map, we don't need it anymore classMap.clear(); classPool = null; }
/** * Maps a class name to another name in this hashtable. * The names are obtained with calling <code>Class.getName()</code>. * This method translates the given class names into the * internal form used in the JVM before putting it in * the hashtable. * * @param oldname the original class name * @param newname the substituted class name. */ public void put(CtClass oldname, CtClass newname) { put(oldname.getName(), newname.getName()); }
/** * Prevents a mapping from the specified class name to another name. */ public void fix(String name) { String name2 = toJvmName(name); super.put(name2, name2); }
/** * Returns a collection of the names of all the classes * referenced in this class. * That collection includes the name of this class. * * <p>This method may return <code>null</code>. * * @return a <code>Collection<String></code> object. */ public synchronized Collection getRefClasses() { ClassFile cf = getClassFile2(); if (cf != null) { ClassMap cm = new ClassMap() { public void put(String oldname, String newname) { put0(oldname, newname); } public Object get(Object jvmClassName) { String n = toJavaName((String)jvmClassName); put0(n, n); return null; } public void fix(String name) {} }; cf.getRefClasses(cm); return cm.values(); } else return null; }
CtMethod originalMethod = method; if (method.getName().equals("getActor")) { ClassMap map = new ClassMap(); map.put(Actor.class.getName(),Actor.class.getName()); method = CtMethod.make( "public "+Actor.class.getName()+" getActor() { return __target; }", cc ) ; } else { ClassMap map = new ClassMap(); map.fix(orig); map.fix(Actor.class.getName()); method = new CtMethod(method, cc, map);
/** * Prevents a mapping from the specified class name to another name. */ public void fix(CtClass clazz) { fix(clazz.getName()); }
/** * Returns the class name to wihch the given <code>jvmClassName</code> * is mapped. A subclass of this class should override this method. * * <p>This method receives and returns the internal representation of * class name used in the JVM. * * @see #toJvmName(String) * @see #toJavaName(String) */ @Override public String get(Object jvmClassName) { String found = super.get(jvmClassName); if (found == null && parent != null) return parent.get(jvmClassName); return found; } /**
JdbcJavassistProxyFactory() { classMap = new ClassMap(); ClassPool defaultPool = ClassPool.getDefault(); classPool = new ClassPool(defaultPool); classPool.insertClassPath(new ClassClassPath(this.getClass())); classPool.childFirstLookup = true; createProxyConnectionClass(); createProxyStatementClass(); createProxyCallableStatementClass(); createProxyPreparedStatementClass(); createProxyResultSetClass(); lrcProxyFactory = new JdbcJavaProxyFactory(); // Clear the map, we don't need it anymore classMap.clear(); classPool = null; }
/** * Maps a class name to another name in this hashtable. * The names are obtained with calling <code>Class.getName()</code>. * This method translates the given class names into the * internal form used in the JVM before putting it in * the hashtable. * * @param oldname the original class name * @param newname the substituted class name. */ public void put(CtClass oldname, CtClass newname) { put(oldname.getName(), newname.getName()); }
/** * Prevents a mapping from the specified class name to another name. */ public void fix(String name) { String name2 = toJvmName(name); super.put(name2, name2); }
}; cf.getRefClasses(cm); return cm.values();