ClassVisitor { public synchronized Set<ConstructId> visitConstructors(boolean _instrument) throws CannotCompileException { final Set<ConstructId> constructs = new HashSet<ConstructId>(); final CtConstructor[] constructors = this.c.getDeclaredConstructors(); String constr_name = null; JavaId jid = null; final String param_to_skip = (this.declaringClass != null && !Modifier.isStatic(this.c.getModifiers()) ? ClassVisitor.removePackageContext(this.declaringClass.getName()) : null); final CtConstructor initializer = this.c.getClassInitializer(); if (initializer != null && this.javaId.getType() == Type.CLASS) { jid = ((JavaClassId) this.javaId).getClassInit(); constructs.add(jid); if (_instrument && !isInstrumented() && !initializer.isEmpty() && initializer.getLongName().startsWith(this.qname)) { try { constr_name = this.removeParameterQualification(initializer.getLongName()); this.instrument(jid, initializer); } catch (CannotCompileException ex) { throw ex; } } } for (CtConstructor constr : constructors) { jid = JavaId.parseConstructorQName( this.javaId.getType(), ClassVisitor.removeParameterQualification(constr.getLongName()), param_to_skip); constructs.add(jid); if (_instrument && !isInstrumented() && !constr.isEmpty() && constr.getLongName().startsWith(this.qname)) { try { constr_name = this.removeParameterQualification(constr.getLongName()); this.instrument(jid, constr); } catch (CannotCompileException ex) { throw ex; } } } ClassVisitor.getLog() .debug("Class '" + this.qname + "': " + constructors.length + " constructors"); return constructs; } ClassVisitor(CtClass _c); Set<ConstructId> getConstructs(); synchronized boolean isInstrumented(); synchronized Set<ConstructId> visitMethods(boolean _instrument); synchronized Set<ConstructId> visitConstructors(boolean _instrument); synchronized void setOriginalArchiveDigest(String _sha1); synchronized void setAppContext(Application _ctx); synchronized void finalizeInstrumentation(); byte[] getBytecode(); synchronized void addBooleanMember(String _field_name, boolean _value, boolean _final); synchronized void addIntMember(String _field_name, boolean _final); String getUniqueMemberName(String _prefix, String _construct_name, boolean _random_part); static String removeParameterQualification(String _string); static String removePackageContext(String _string); JavaId getJavaId(); CtClass getCtClass(); String getArchiveDigest(); synchronized Application getAppContext(); String getQname(); synchronized String getOriginalArchiveDigest(); static final String prettyPrint(String _src);  }
@Test public void testNonStaticInnerClassConstructor() { try { final JavaClassId cid = JavaId.parseClassQName("org.eclipse.steady.java.monitor.ClassVisitorTest$NonStaticInner"); final ClassPool cp = ClassPool.getDefault(); final CtClass ctclass = cp.get(cid.getQualifiedName()); final ClassVisitor cv = new ClassVisitor(ctclass); final Set<ConstructId> constructors = cv.visitConstructors(false); final JavaConstructorId expected = JavaId.parseConstructorQName( "org.eclipse.steady.java.monitor.ClassVisitorTest$NonStaticInner(Map)"); assertEquals(expected, constructors.iterator().next()); } catch (NotFoundException e) { System.err.println(e.getMessage()); assertTrue(false); } catch (CannotCompileException e) { System.err.println(e.getMessage()); assertTrue(false); } }