Hi,
I'm using bcel library to dynamically instrument java
classes. I'm using JVMPI_EVENT_CLASS_LOAD_HOOK event
to get the class bytes just before loading it. Once I
get the correct class to instrument, I instrument all
the methods (other than abstract & native)to get the
method entry & exit notifications. This methodology is
working fine for all the classes except for java
classes. On saving the instrumented class on the disk
and de compiling it shows that the class has been
instrumented properly, but during execution I get
ClassNotFoundError.
e.g. If I instrument sun.jdbc.odbc.JdbcOdbcStatement
class's public ResultSet executeQuery(String s)
throws SQLException method
Original methods:
public ResultSet executeQuery(String s)
throws SQLException
{
if(OdbcApi.getTracer().isTracing())
OdbcApi.getTracer().trace("*Statement.executeQuery ("
+ s + ")");
ResultSet resultset = null;
if(execute(s))
resultset = getResultSet(false);
else
throw new SQLException("No ResultSet was
produced");
if(batchOn)
clearBatch();
return resultset;
}
After instrumentation:
public ResultSet executeQuery(String s)
throws SQLException
{
try
{
MyClass.queryFiredStart(s,
"sun.jdbc.odbc.JdbcOdbcStatement");
if(OdbcApi.getTracer().isTracing())
OdbcApi.getTracer().trace("*Statement.executeQuery ("
+ s + ")");
ResultSet resultset = null;
if(execute(s))
resultset = getResultSet(false);
else
throw new SQLException("No ResultSet was
produced");
if(batchOn)
clearBatch();
return resultset;
}
finally
{
MyClass.queryFiredEnd(s,
"sun.jdbc.odbc.JdbcOdbcStatement");
}
}
Note the difference of adding try-finally block. The
import of MyClass is also present at the top of
instrumented class.
But when this class is loaded, I get
ClassNotFoundError for MyClass.
This holds true for other classes like
java.util.Vector, in general, classes belonging to
rt.jar. Is this related to rt.jar?
Am I missing any thing or we cannot instrument java's
core classes?
Can any one help me in this issue?
Regards,
Amol
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]