Se obtiene un error en la instrumentaciónError al instrumentar los archivos de clase (asm.ClassWriter.getCommonSuperClass)
java.lang.RuntimeException: java.lang.ClassNotFoundException: Deposit
at org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)
at org.objectweb.asm.ClassWriter.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at com.jConSequence.instrumentor.methodProber.AdddataBaseDetailsInstructions$AdddataBaseDetailsMethodInstructions.visitMaxs(AdddataBaseDetailsInstructions.java:131)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.jConSequence.instrumentor.PrintLoadedClasses.print(PrintLoadedClasses.java:31)
at com.jConSequence.tooGUI.RevEnggToolGUI.jButton1ActionPerformed(RevEnggToolGUI.java:487)
at com.jConSequence.tooGUI.RevEnggToolGUI.access$0(RevEnggToolGUI.java:471)
at com.jConSequence.tooGUI.RevEnggToolGUI$1.actionPerformed(RevEnggToolGUI.java:127)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
mientras que la instrumentación de clases
D:\workspaces\workspace\bankManagement\bin\Account.class
D:\workspaces\workspace\bankManagement\bin\ATM.class
D:\workspaces\workspace\bankManagement\bin\ATMCaseStudy.class
D:\workspaces\workspace\bankManagement\bin\BalanceInquiry.class
D:\workspaces\workspace\bankManagement\bin\BankDatabase.class
D:\workspaces\workspace\bankManagement\bin\CashDispenser.class
D:\workspaces\workspace\bankManagement\bin\Deposit.class
D:\workspaces\workspace\bankManagement\bin\DepositSlot.class
D:\workspaces\workspace\bankManagement\bin\Keypad.class
D:\workspaces\workspace\bankManagement\bin\Screen.class
D:\workspaces\workspace\bankManagement\bin\Transaction.class
Estoy leyendo el anterior conjunto de clases como flujos de bytes usando Apache commonsIO .
Luego, use la biblioteca asm para instrumentarlos.
Finalmente se convierten en archivos de clase.
Es en este punto de la instrumentación que estoy recibiendo este error ¿Alguien puede explicar amablemente la razón y la posible solución?
Estoy tratando de implementar getCommonSuperClass, y para obtener las clases cargadas, estoy usando el objeto de instrumentación, es decir, instrumentObj.getAllLoadedClasses(). Pero, ¿y si algunas clases no están presentes aquí también? – AKS
@AKS Probablemente sea mejor comenzar una nueva pregunta y hacer referencia a esta respuesta que comentar una respuesta tan antigua. Dicho esto, no hay magia aquí: tienes que obtener de alguna manera la respuesta. Si intentas usar getAllLoadedClasses pero la clase no está cargada, tendrás que hacer otra cosa para obtener una respuesta (por ejemplo, usa getResource para buscar los bytes de clase para encontrar la respuesta). –
Ya, comenzó una nueva pregunta. ¡Gracias! – AKS