function Clazz() {}; Clazz.staticMethod = function() { alert('STATIC!!!'); }; Clazz.prototype.func = function() { this.constructor.staticMethod(); } var obj = new Clazz(); obj.func(); // <- Alert's "STATIC!!!"
// Pass as parameter. foo(new Clazz( ) { // Do stuff. } ); void func () { foo(new Clazz( ) { // Do stuff. } ); } // Assign to variable. Clazz bar = new Clazz( ) { // Do stuff. };
Map <MyKeys, Clazz> zzz = new HashMap<MyKeys, String>(); // this means it won't return null, the value is initialized zzz.put(MyKeys.BKEY, new Clazz()); // this is confusing part ... somevalues might be null zzz.get(MyKeys.BKEY).setValues(someValues); Clazz xxx = zzz.get(MyKeys.BKEY); //definitely won't return null
x.setFoo("new foo"); x = new Clazz(); x.setFoo("yet another foo"); System.out.println(y.getFoo()); // Would print "new foo"
Clazz instanceOfClazz = new Clazz(); System.out.println(instanceOfClazz.variable);
public static void main(String[] args) { Integer i = Integer.valueOf(300); new Clazz() { void foo() { System.out.println(this.val$i); } } .foo(); }
/** * Find a clazz on the class path. This class has been parsed. * * @param path * @return */ public Clazz findClass(TypeRef typeRef) throws Exception { Clazz c = classspace.get(typeRef); if (c != null) return c; c = importedClassesCache.get(typeRef); if (c != null) return c; Resource r = findResource(typeRef.getPath()); if (r == null) { getClass().getClassLoader(); URL url = ClassLoader.getSystemResource(typeRef.getPath()); if (url != null) r = new URLResource(url); } if (r != null) { c = new Clazz(this, typeRef.getPath(), r); c.parseClassFile(); importedClassesCache.put(typeRef, c); } return c; }
/** * Find a clazz on the class path. This class has been parsed. * * @param path * @return */ public Clazz findClass(TypeRef typeRef) throws Exception { Clazz c = classspace.get(typeRef); if (c != null) return c; c = importedClassesCache.get(typeRef); if (c != null) return c; Resource r = findResource(typeRef.getPath()); if (r == null) { getClass().getClassLoader(); URL url = ClassLoader.getSystemResource(typeRef.getPath()); if (url != null) r = new URLResource(url); } if (r != null) { c = new Clazz(this, typeRef.getPath(), r); c.parseClassFile(); importedClassesCache.put(typeRef, c); } return c; }
if (path.endsWith(".class")) { entries.add(path.substring(0, path.length() - ".class".length())); final Clazz cls = new Clazz(analyzer, path, new InputStreamResource(new BufferedInputStream(new UnclosableFilterInputStream(zin)))); final ScanResult scanResult = ClassBinaryScanner.scanClassBinary(cls);
/** * Find a clazz on the class path. This class has been parsed. */ public Clazz findClass(TypeRef typeRef) throws Exception { Clazz c = classspace.get(typeRef); if (c != null) return c; c = importedClassesCache.get(typeRef); if (c != null) return c; Resource r = findResource(typeRef.getPath()); if (r == null) { getClass().getClassLoader(); URL url = ClassLoader.getSystemResource(typeRef.getPath()); if (url != null) r = Resource.fromURL(url, getPlugin(HttpClient.class)); } if (r != null) { c = new Clazz(this, typeRef.getPath(), r); c.parseClassFile(); importedClassesCache.put(typeRef, c); } return c; }
/** * Find a clazz on the class path. This class has been parsed. * * @param path * @return */ public Clazz findClass(TypeRef typeRef) throws Exception { Clazz c = classspace.get(typeRef); if (c != null) return c; c = importedClassesCache.get(typeRef); if (c != null) return c; Resource r = findResource(typeRef.getPath()); if (r == null) { getClass().getClassLoader(); URL url = ClassLoader.getSystemResource(typeRef.getPath()); if (url != null) r = new URLResource(url); } if (r != null) { c = new Clazz(this, typeRef.getPath(), r); c.parseClassFile(); importedClassesCache.put(typeRef, c); } return c; }
/** * Find a clazz on the class path. This class has been parsed. */ public Clazz findClass(TypeRef typeRef) throws Exception { Clazz c = classspace.get(typeRef); if (c != null) return c; c = importedClassesCache.get(typeRef); if (c != null) return c; Resource r = findResource(typeRef.getPath()); if (r == null) { getClass().getClassLoader(); URL url = ClassLoader.getSystemResource(typeRef.getPath()); if (url != null) r = Resource.fromURL(url, getPlugin(HttpClient.class)); } if (r != null) { c = new Clazz(this, typeRef.getPath(), r); c.parseClassFile(); importedClassesCache.put(typeRef, c); } return c; }
final ScanResult scanResult = ClassBinaryScanner.scanClassBinary(new Clazz(new Analyzer(), className, classBinaryResource));
/** * Visit each class on the class path. * * @param visitor the visitor */ public void visit(ClassVisitor visitor) throws Exception { try (Analyzer analyzer = new Analyzer()) { for (File f : entries) { try (Jar jar = new Jar(f)) { for (String path : jar.getResources() .keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } } } }
/** * Visit each class on the class path. * * @param visitor the visitor */ public void visit(ClassVisitor visitor) throws Exception { try (Analyzer analyzer = new Analyzer()) { for (File f : entries) { try (Jar jar = new Jar(f)) { for (String path : jar.getResources() .keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } } } }
/** * Visit each class on the class path. * * @param visitor the visitor */ public void visit(ClassVisitor visitor) throws Exception { try (Analyzer analyzer = new Analyzer()) { for (File f : entries) { try (Jar jar = new Jar(f)) { for (String path : jar.getResources() .keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } } } }
/** * Visit each class on the class path. * * @param visitor the visitor */ public void visit(ClassVisitor visitor) throws Exception { try (Analyzer analyzer = new Analyzer()) { for (File f : entries) { try (Jar jar = new Jar(f)) { for (String path : jar.getResources() .keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } } } }
/** * Visit each class on the class path. * * @param visitor * the visitor */ public void visit(ClassVisitor visitor) throws Exception { Analyzer analyzer = new Analyzer(); try { for (File f : entries) { Jar jar = new Jar(f); try { for (String path : jar.getResources().keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } finally { jar.close(); } } } finally { analyzer.close(); } }
/** * Visit each class on the class path. * * @param visitor * the visitor */ public void visit(ClassVisitor visitor) throws Exception { Analyzer analyzer = new Analyzer(); try { for (File f : entries) { Jar jar = new Jar(f); try { for (String path : jar.getResources().keySet()) { if (path.endsWith(".class")) { Resource r = jar.getResource(path); Clazz c = new Clazz(analyzer, path, r); c.parseClassFile(); visitor.visit(c); } } } finally { jar.close(); } } } finally { analyzer.close(); } }