|
1 | 1 | package com.laytonsmith.PureUtilities.ClassLoading; |
2 | 2 |
|
3 | 3 | import com.laytonsmith.PureUtilities.ClassLoading.ClassMirror.ClassMirror; |
| 4 | +import com.laytonsmith.PureUtilities.ClassLoading.ClassMirror.ClassMirrorVisitor; |
4 | 5 | import com.laytonsmith.PureUtilities.ClassLoading.ClassMirror.ClassReferenceMirror; |
5 | 6 | import com.laytonsmith.PureUtilities.ClassLoading.ClassMirror.FieldMirror; |
6 | 7 | import com.laytonsmith.PureUtilities.ClassLoading.ClassMirror.MethodMirror; |
|
34 | 35 | import java.util.logging.Logger; |
35 | 36 | import java.util.regex.Pattern; |
36 | 37 |
|
| 38 | +import org.objectweb.asm.ClassReader; |
| 39 | + |
37 | 40 | /** |
38 | 41 | * This class contains methods for dynamically determining things about Classes, |
39 | 42 | * without loading them into PermGen. Search criteria is provided, (most notably |
@@ -301,8 +304,10 @@ private synchronized void discover(URL rootLocation) { |
301 | 304 | try { |
302 | 305 | stream = FileUtil.readAsStream(new File(rootLocationFile, |
303 | 306 | f.getAbsolutePath().replaceFirst(Pattern.quote(new File(root).getAbsolutePath() + File.separator), ""))); |
304 | | - ClassMirror cm = new ClassMirror(stream, new URL(url)); |
305 | | - mirrors.add(cm); |
| 307 | + ClassReader reader = new ClassReader(stream); |
| 308 | + ClassMirrorVisitor mirrorVisitor = new ClassMirrorVisitor(); |
| 309 | + reader.accept(mirrorVisitor, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); |
| 310 | + mirrors.add(mirrorVisitor.getMirror(new URL(url))); |
306 | 311 | } catch (IOException ex) { |
307 | 312 | Logger.getLogger(ClassDiscovery.class.getName()).log(Level.SEVERE, null, ex); |
308 | 313 | } finally { |
@@ -334,8 +339,10 @@ private synchronized void discover(URL rootLocation) { |
334 | 339 | public void handle(String filename, InputStream in) { |
335 | 340 | if (!filename.matches(".*\\$(?:\\d)*\\.class") && filename.endsWith(".class")) { |
336 | 341 | try { |
337 | | - ClassMirror cm = new ClassMirror(in, rootLocationFile.toURI().toURL()); |
338 | | - mirrors.add(cm); |
| 342 | + ClassReader reader = new ClassReader(in); |
| 343 | + ClassMirrorVisitor mirrorVisitor = new ClassMirrorVisitor(); |
| 344 | + reader.accept(mirrorVisitor, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); |
| 345 | + mirrors.add(mirrorVisitor.getMirror(rootLocationFile.toURI().toURL())); |
339 | 346 | } catch (IOException ex) { |
340 | 347 | Logger.getLogger(ClassDiscovery.class.getName()).log(Level.SEVERE, null, ex); |
341 | 348 | } |
|
0 commit comments