Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6289149
Votes 0
Synopsis Java Agent will pick wrong execution path while attaching.
Category java:serviceability
Reported Against
Release Fixed 7(b26)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 22-JUN-2005
Description
Source:
http://oldsunweb.ireland/~ab23780/mustang/282/j2se/webrev/src/share/classes/sun/instrument/InstrumentationImpl.java.html
<your code>
166         try {
167             m = javaAgentClass.getMethod( methodname,
168                                           new Class[] { 
169                                               String.class,
170                                               java.lang.instrument.Instrumentation.class
171                                           }
172                                         );
173             twoArgAgent = true;
174         } catch (NoSuchMethodException x) {
175             // remember the NoSuchMethodException 
176             firstExc = x;
177         }
178 
179         // check for the 1-arg method
180         if (m == null) {
181             try {
182                 m = javaAgentClass.getMethod(methodname, new Class[] { String.class });
183             } catch (NoSuchMethodException x) {
184                 // Neither method exists so we throw the first NoSuchMethodException
185                 // as per 5.0
186                 throw firstExc;
187             }
188         }
189 
190         // invoke the 1 or 2-arg method 
191         if (twoArgAgent) {
192             m.invoke(null, new Object[] { optionsString, this });
193         } else {
194             m.invoke(null, new Object[] { optionsString });
195         }
<your code>
  xxxxx@xxxxx   2005-06-22  customer :12:48 GMT

<moved problem description here from comment note #1>

This code can cause a small issue.
if my agentclass has a super class or interfaces that has a two parameter method, then we will pick up a wrong path.
Some thing like this.
public class X {
   public static void premain/agentmain() // two parameter method.
}
public class Y extends X {
   public static void    premain/agentMain() // single parameter method.
}
if my manifest has
    Agent-Class: Y
then
Y.class.getMethod("premain",new Class[] {String.class, String.class}) --> X.premain(String, String);
Y.class.getDeclaredMethod("premain",new Class[] {String.class, String.class}) --> null;

We will start agent running from X, instead of Y, because we will get two parameter method from X first.
  xxxxx@xxxxx   2005-06-22  customer :12:48 GMT
Posted Date : 2008-02-16 02:43:21.0

The code is a little bit different in Dolphin-B24, but
the bug is still there.
Posted Date : 2008-02-16 01:24:38.0

The following two new tests will fail without this fix in
a promoted JDK:

    java/lang/instrument/PremainClass/InheritAgent1001.java
    java/lang/instrument/PremainClass/InheritAgent1101.java
Posted Date : 2008-02-21 06:08:16.0
Work Around
N/A
Evaluation
The submitter is correct and goes back to the original JPLIS implementation. Unlikely to occur in practice but should be fixed.
  xxxxx@xxxxx   2005-06-22 03:20:45 GMT
The submitter is mostly right. We need to check:

    1) declared with a signature of (String, Instrumentation)
    2) declared with a signature of (String)
    3) inherited with a signature of (String, Instrumentation)
    4) inherited with a signature of (String)

The more important part of this bug is that we need some
tests for the various premain() combinations.
Posted Date : 2008-02-16 03:18:51.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang