Differences between revisions 1 and 2
Revision 1 as of 2006-08-04 03:38:17
Size: 1303
Editor: lvjing
Comment:
Revision 2 as of 2009-09-20 21:55:20
Size: 1303
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
        Manifest-Version: 1.0[[BR]]
        Created-By: 1.5.0_06 (Sun Microsystems Inc.)[[BR]]
        Premain-Class: !PreMain[[BR]]
        Boot-Class-Path: .[[BR]]
        Manifest-Version: 1.0<<BR>>
        Created-By: 1.5.0_06 (Sun Microsystems Inc.)<<BR>>
        Premain-Class: !PreMain<<BR>>
        Boot-Class-Path: .<<BR>>

INSTRUMENT TEST

This page describe the detail of non-unit-test of instrument.

How to build a test

A.Create a test class, e.g, "test.java". Do something in method main().

B.Create a class with a method "Premain":

  • public static void premain(String agentArgs, Instrumentation inst); "inst" is one instance of the implement of Instrument in Harmony. You can test any function of the Instrumentation here.

C.Create a jar file, e.g, "test.jar", with Premain-class attribute which denotes the class "PreMain" in the manifest. It is convenience to pack "PreMain.class" in it.

  • An example:
    • (1)create a manifest called Manifest with such content:

      Manifest-Version: 1.0
      Created-By: 1.5.0_06 (Sun Microsystems Inc.)
      Premain-Class: PreMain
      Boot-Class-Path: .
      (2)create the jar: jar cvfm Test.jar Manifest Premain.class

D.lauch Java VM with the following options:

  • java -agentlib:Path InstrumentDLLName=test.jar Main

Here VMPath is the path of InstrumentDLLName; InstrumentDLLName is the name(without suffix) of a instrument dll file

  • If Launcher with parameter "-javaagent" is ready, then we can lauch: java -javaagent:test.jar Main

Test descriptions

INSTRUMENT_TEST (last edited 2009-09-20 21:55:20 by localhost)