[
https://issues.jboss.org/browse/JASSIST-260?page=com.atlassian.jira.plugi...
]
Rafael Campos updated JASSIST-260:
----------------------------------
Steps to Reproduce:
Stack frame corruption after writing to attribute contain on class that contains method
with injected code via
{code:java}
CtMethod.insertAfter(String src)
{code}
This writing happens inside of the injected code src it self.
Example:
{code:java}
public class Animal {
public String ret;
public AnimalRoles(){
ret = "Before";
}
public String hello() {
return ret;
}
public String die(String age) {
return "";
}
}
{code}
{code:java}
// Somehow get the method hello from Animal into a var name methodHello
method.insertAfter("this.ret = \"After\";");
{code}
{code:java}
// Call the method hello in a fresh Animal instance
Animal a = new Animal();
System.out.println(a.hello());
System.out.println(a.ret);
{code}
Result:
Before
After
Expected:
After
After
Debugging the program a in the method hello it is possible to observe the following
message:
"com.sun.jdi.InternalException: Got error code in repIy:35 occurred retrieving
‘this' from stack frame."
!Image1.png|thumbnail!
Tried several work arounds but basically the problem is that the newly written data can
not be read at the return statement. No workaround found so far.
Also tested with previous versions of javaassist from 3.12.1.GA until 3.20.0GA and all
yield the same result.
Tried search the web for similar issues but with very little luck. Just some cryptic
message with some weird workarounds that I could not get to work by any means.
was:
Stack frame corruption after writing to attribute contain on class that contains method
with injected code via
{code:java}
CtMethod.insertAfter(String src)
{code}
This writing happens inside of the injected code src it self.
Example:
{code:java}
public class Animal {
public String ret;
public AnimalRoles(){
ret = "Before";
}
public String hello() {
return ret;
}
public String die(String age) {
return "";
}
}
{code}
{code:java}
// Somehow get the method hello from Animal into a var name methodHello
method.insertAfter("this.ret = \"After\";");
{code}
{code:java}
// Call the method hello in a fresh Animal instance
Animal a = new Animal();
System.out.println(a.hello());
System.out.println(a.ret);
{code}
Result:
Before
After
Expected:
After
After
Debugging the program a in the method hello it is possible to observe the following
message:
"com.sun.jdi.InternalException: Got error code in repIy:35 occurred retrieving
‘this' from stack frame."
!Image1.png|thumbnail!
Tried several work around but basically the problem is that the newly written that can not
be read at the return statement. No workaround found so far.
Also tested with previous versions of javaassist from 3.12.1.GA until 3.20.0GA and all
yield the same result.
Tried search the web for similar issues but with very little luck. Just some cryptic
message with some weird workarounds that I could not get to work by any means.
Stack frame corruption after writing to attribute on injected after
method
--------------------------------------------------------------------------
Key: JASSIST-260
URL:
https://issues.jboss.org/browse/JASSIST-260
Project: Javassist
Issue Type: Bug
Affects Versions: 3.20.0-GA
Environment: Using java 1.8, also tested with java 1.7 same behavior on eclipse
Version: Mars.1 Release (4.5.1) on windows 7 x64 bits.
Reporter: Rafael Campos
Assignee: Shigeru Chiba
Priority: Minor
Attachments: Image1.png
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)