/** * Returns the fully qualified class name, i.e., including the name of the package in which the class is defined. */ @Override public String getQualifiedName() { if(this.declarationContext!=null) { if(!this.isNested()) return this.declarationContext.getQualifiedName() + "." + this.enumName; else return this.declarationContext.getQualifiedName() + "$" + this.enumName; } else { return this.enumName; } }
/** * Returns the fully qualified interface name, i.e., including the name of the package in which it is defined. */ @Override public String getQualifiedName() { if(this.declarationContext!=null) { if(!this.isNested()) return this.declarationContext.getQualifiedName() + "." + this.interfaceName; else return this.declarationContext.getQualifiedName() + "$" + this.interfaceName; } else { return this.interfaceName; } }
/** * Returns the fully qualified constructor name, including package and (unqualified) parameter types. * Example: test.package.TestClass(int) */ public String getQualifiedName() { return context.getQualifiedName() + JavaId.parameterTypesToString(this.parameterTypes, true); }
@Override public final boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; JavaId other = (JavaId) obj; if (type != other.type) return false; if (!this.getQualifiedName().equals(other.getQualifiedName())) return false; return true; }
/** * Returns the fully qualified name, i.e., with parameter types and the surrounding class. */ public String getQualifiedName() { return context.getQualifiedName() + "." + this.methodId + JavaId.parameterTypesToString(this.parameterTypes, true); }
JavaId.log.warn("[" + this.getQualifiedName() + "] is a package, thus, has no compilation unit"); JavaId.log.error("[" + this.getQualifiedName() + "] is of unknown type (class [" + this.getClass().getName() + "]");
/** * Returns the fully qualified class name, i.e., including the name of the package in which the class is defined. */ @Override public String getQualifiedName() { final StringBuilder builder = new StringBuilder(); if(this.declarationContext!=null) { final String prefix = this.declarationContext.getQualifiedName(); builder.append(prefix); // Empty string in case of default package // Outer class if(!this.isNestedClass()) { if(!prefix.equals("")) // Could also use JavaPackageId.isDefaultPackage builder.append("."); } // Inner class else { if(!prefix.equals("")) // Should probably never happen builder.append("$"); } } builder.append(this.className); return builder.toString(); }
@Override public JsonObject toGSON(){ final JsonObject jb = new JsonObject(); jb.addProperty("lang", this.getLanguage().toString()); jb.addProperty("type", JavaId.typeToString(this.getType())); jb.addProperty("qname", this.getQualifiedName()); jb.add("a", new Gson().toJsonTree(this.annotations)); return jb; }
@Override public final int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + (this.getQualifiedName().hashCode()); return result; } @Override
/** * Returns true if the given JavaId has the annotation "org.junit.Test" and the stack trace util has been configured to stop at JUnit tests, false otherwise. * @param _jid the JavaId whose annotations are checked * @return */ private boolean continueStacktraceTransformation(JavaId _jid) { boolean cont = true; if(_jid==null) cont = false; else if(_jid.hasAnnotation(ANNO_JUNIT_TEST)) { if(this.stopAtJUnit) { StackTraceUtil.getLog().debug("Found JUnit test [" + _jid.getQualifiedName() + "]: Stop path construction"); cont = false; } else StackTraceUtil.getLog().debug("Found JUnit test [" + _jid.getQualifiedName() + "]"); } return cont; }
url = Class.forName(this.getQualifiedName()).getResource('/' + this.getQualifiedName().replace('.', '/') + ".class"); } catch (ClassNotFoundException e) { JavaId.log.error("Class [" + this.getQualifiedName() + "] not found: " + e.getMessage()); } catch (NoClassDefFoundError ex) { JavaId.log.error("No class definition found for [" + this.getQualifiedName() + "]"); } catch(UnsatisfiedLinkError e){ JavaId.log.error("UnsatisfiedLinkError for [" + this.getQualifiedName() + "]");
public String toString() { return this.getLanguage() + " " + JavaId.typeToString(this.type) + " [" + this.getQualifiedName() + "]"; }
def_ctx = this.getCompilationUnit(jid); log.debug("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); file = ClassDownloader.getInstance().getClass(mvnGroup, artifact, version, def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA); response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot retrieve class [" + def_ctx.getQualifiedName() + "]"); response.flushBuffer();
log.info("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); file = ClassDownloader.getInstance().getClass(doc.getLibId().getMvnGroup(), doc.getLibId().getArtifact(), doc.getLibId().getVersion(), def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA); log.warn("Cannot retrieve class [" + def_ctx.getQualifiedName() + "]"); return new ResponseEntity<ASTConstructBodySignature>(HttpStatus.NOT_FOUND); return new ResponseEntity<ASTConstructBodySignature>(sign, HttpStatus.OK); else { log.warn("Cannot construct signature for class [" + def_ctx.getQualifiedName() + "] in SHA1: " + sha1); return new ResponseEntity<ASTConstructBodySignature>(sign, HttpStatus.NOT_FOUND);
def_ctx = this.getCompilationUnit(jid); log.debug("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); file = ClassDownloader.getInstance().getClass(doc.getLibId().getMvnGroup(), doc.getLibId().getArtifact(), doc.getLibId().getVersion(), def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA); response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot retrieve class [" + def_ctx.getQualifiedName() + "]"); response.flushBuffer();
public ClassVisitor(CtClass _c) { // Build the JavaId if(_c.isInterface()) throw new IllegalArgumentException("[" + _c.getName() + "]: Interfaces are not supported"); else if(_c.isEnum()) this.javaId = JavaId.parseEnumQName(_c.getName()); else this.javaId = JavaId.parseClassQName(_c.getName()); this.qname = this.javaId.getQualifiedName(); this.c = _c; // Remember major/minor final ClassFile cf = _c.getClassFile(); this.major = cf.getMajorVersion(); this.minor = cf.getMinorVersion(); // For nested classes, get the declaring (outer) class: It is used to skip the first argument in non-static inner classes try { this.declaringClass = _c.getDeclaringClass(); } catch (NotFoundException e) { // Only a problem in case of non-static inner classes, because in that case the 1st argument of the constructor cannot be removed, cf. method visitConstructors(boolean) if(!Modifier.isStatic(this.c.getModifiers())) ClassVisitor.getLog().warn("No declaring class found for non-static inner class [" + this.javaId.getQualifiedName() + "]");//: " + e.getMessage()); } writeCodeToTmp = VulasConfiguration.getGlobal().getConfiguration().getBoolean(CoreConfiguration.INSTR_WRITE_CODE, false); }
log.debug("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); if(sources) file = ClassDownloader.getInstance().getClass(mvnGroup, artifact, version, def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA); else file = ClassDownloader.getInstance().getClass(mvnGroup, artifact, version, def_ctx.getQualifiedName(), ClassDownloader.Format.CLASS); if(file==null) { log.warn("Cannot retrieve class [" + def_ctx.getQualifiedName() + "]"); return new ResponseEntity<Signature>(HttpStatus.NOT_FOUND); log.warn("Cannot construct signature for class [" + def_ctx.getQualifiedName() + "]"); return new ResponseEntity<Signature>(HttpStatus.NOT_FOUND);
this.instrControl.updateInstrumentationStatistics(cv.getJavaId(), new Boolean(true)); } catch (IOException ioe) { WarAnalyzer.log.error("I/O exception while instrumenting class [" + cv.getJavaId().getQualifiedName() + "]: " + ioe.getMessage()); this.instrControl.updateInstrumentationStatistics(cv.getJavaId(), new Boolean(false)); } catch (CannotCompileException cce) { WarAnalyzer.log.warn("Cannot compile instrumented class [" + cv.getJavaId().getQualifiedName() + "]: " + cce.getMessage()); this.instrControl.updateInstrumentationStatistics(cv.getJavaId(), new Boolean(false)); } catch (Exception e) { WarAnalyzer.log.error(e.getClass().getName() + " occured while instrumenting class [" + cv.getJavaId().getQualifiedName() + "]: " + e.getMessage()); this.instrControl.updateInstrumentationStatistics(cv.getJavaId(), new Boolean(false)); WarAnalyzer.log.error("Error while analyzing class [" + cv.getJavaId().getQualifiedName() + "]: " + nfe.getMessage()); continue; } catch (RuntimeException re) {
ClassPool cp = ClassPoolUpdater.getInstance().getCustomClassPool(); if(cp==null)cp=ClassPool.getDefault(); clazz = cp.get(comp_unit.getQualifiedName()); declaringClass = clazz.getDeclaringClass(); final String param_to_skip = ( declaringClass!=null && !Modifier.isStatic(clazz.getModifiers()) ? ClassVisitor.removePackageContext(declaringClass.getName()) : null );
public final String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("lang", this.getLanguage().toString()); jb.appendObjectProperty("type", JavaId.typeToString(this.getType())); jb.appendObjectProperty("qname", this.getQualifiedName()); if(!this.annotations.isEmpty()) { jb.startArrayProperty("a"); for(String a: this.annotations) { jb.appendToArray(a); } jb.endArray(); } jb.endObject(); return jb.getJson(); }