• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Using ASM bytecode manipulation to transorm a class gives error

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to ASM and I'm trying to do a basic transformation of a class at runtime. To get me started, I'm trying to transform a class simply by changing its name by appending the word "String" to the end of it. After performing this transformation I try to instantiate an object of the newly generated class. When I run my code I get this error message:

Exception in thread "main" java.lang.VerifyError: stack shape inconsistent (class: beans/PersonString method: getName()Ljava/lang/String;) at pc: 1
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:69)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:131)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at beans.ConvertClass.main(ConvertClass.java:27)

This is my main method



This is my change adapter



This is my class loader



The main method fails on line 27 where I try to instantiate an object from the new class.

Any feedback would be greatly appreciated.

Thanks,
Ajay
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic