3838import java .text .DateFormat ;
3939import java .text .SimpleDateFormat ;
4040import java .util .ArrayList ;
41- import java .util .Arrays ;
4241import java .util .ConcurrentModificationException ;
4342import java .util .Date ;
4443import java .util .List ;
7675import com .oracle .svm .configure .filters .HierarchyFilterNode ;
7776import com .oracle .svm .configure .trace .AccessAdvisor ;
7877import com .oracle .svm .configure .trace .TraceProcessor ;
79- import com .oracle .svm .core .SubstrateUtil ;
8078import com .oracle .svm .core .configure .ConfigurationFile ;
8179import com .oracle .svm .core .jni .headers .JNIEnvironment ;
8280import com .oracle .svm .core .jni .headers .JNIJavaVM ;
8381import com .oracle .svm .core .jni .headers .JNIObjectHandle ;
84- import com .oracle .svm .driver .NativeImage ;
8582import com .oracle .svm .driver .metainf .NativeImageMetaInfWalker ;
8683import com .oracle .svm .jvmtiagentbase .JNIHandleSet ;
8784import com .oracle .svm .jvmtiagentbase .JvmtiAgentBase ;
@@ -143,7 +140,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
143140 boolean experimentalClassDefineSupport = false ;
144141 boolean experimentalUnsafeAllocationSupport = false ;
145142 boolean experimentalOmitClasspathConfig = false ;
146- boolean build = false ;
147143 boolean configurationWithOrigins = false ;
148144 List <String > conditionalConfigUserPackageFilterFiles = new ArrayList <>();
149145 List <String > conditionalConfigClassNameFilterFiles = new ArrayList <>();
@@ -206,8 +202,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
206202 if (configWritePeriodInitialDelay < 0 ) {
207203 return usage (1 , "config-write-initial-delay-secs must be an integer greater or equal to 0" );
208204 }
209- } else if (isBooleanOption (token , "build" )) {
210- build = getBooleanTokenValue (token );
211205 } else if (isBooleanOption (token , "experimental-configuration-with-origins" )) {
212206 configurationWithOrigins = getBooleanTokenValue (token );
213207 } else if (token .startsWith ("experimental-conditional-config-filter-file=" )) {
@@ -223,9 +217,9 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
223217 }
224218 }
225219
226- if (traceOutputFile == null && configOutputDir == null && ! build ) {
220+ if (traceOutputFile == null && configOutputDir == null ) {
227221 configOutputDir = transformPath (AGENT_NAME + "_config-pid{pid}-{datetime}/" );
228- inform ("no output/build options provided, tracking dynamic accesses and writing configuration to directory: " + configOutputDir );
222+ inform ("no output options provided, tracking dynamic accesses and writing configuration to directory: " + configOutputDir );
229223 }
230224
231225 if (configurationWithOrigins && !conditionalConfigUserPackageFilterFiles .isEmpty ()) {
@@ -377,14 +371,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
377371 }
378372 }
379373
380- if (build ) {
381- int status = buildImage (jvmti );
382- if (status == 0 ) {
383- System .exit (status );
384- }
385- return status ;
386- }
387-
388374 try {
389375 BreakpointInterceptor .onLoad (jvmti , callbacks , tracer , this , interceptedStateSupplier ,
390376 experimentalClassLoaderSupport , experimentalClassDefineSupport , experimentalUnsafeAllocationSupport , trackReflectionMetadata );
@@ -504,46 +490,6 @@ private static void ignoreConfigFromClasspath(JvmtiEnv jvmti, ConfigurationFileC
504490 private static final Pattern propertyBlacklist = Pattern .compile ("(java\\ ..*)|(sun\\ ..*)|(jvmci\\ ..*)" );
505491 private static final Pattern propertyWhitelist = Pattern .compile ("(java\\ .library\\ .path)|(java\\ .io\\ .tmpdir)" );
506492
507- private static int buildImage (JvmtiEnv jvmti ) {
508- System .out .println ("Building native image ..." );
509- String classpath = Support .getSystemProperty (jvmti , "java.class.path" );
510- if (classpath == null ) {
511- return usage (1 , "Build mode could not determine classpath." );
512- }
513- String javaCommand = Support .getSystemProperty (jvmti , "sun.java.command" );
514- String mainClassMissing = "Build mode could not determine main class." ;
515- if (javaCommand == null ) {
516- return usage (1 , mainClassMissing );
517- }
518- String mainClass = SubstrateUtil .split (javaCommand , " " )[0 ];
519- if (mainClass .isEmpty ()) {
520- return usage (1 , mainClassMissing );
521- }
522- List <String > buildArgs = new ArrayList <>();
523- // buildArgs.add("--verbose");
524- String [] keys = Support .getSystemProperties (jvmti );
525- for (String key : keys ) {
526- boolean whitelisted = propertyWhitelist .matcher (key ).matches ();
527- boolean blacklisted = !whitelisted && propertyBlacklist .matcher (key ).matches ();
528- if (blacklisted ) {
529- continue ;
530- }
531- buildArgs .add ("-D" + key + "=" + Support .getSystemProperty (jvmti , key ));
532- }
533- if (mainClass .toLowerCase ().endsWith (".jar" )) {
534- buildArgs .add ("-jar" );
535- } else {
536- buildArgs .addAll (Arrays .asList ("-cp" , classpath ));
537- }
538- buildArgs .add (mainClass );
539- buildArgs .add (AGENT_NAME + ".build" );
540- // System.out.println(String.join("\n", buildArgs));
541- Path javaHome = Paths .get (Support .getSystemProperty (jvmti , "java.home" ));
542- String userDirStr = Support .getSystemProperty (jvmti , "user.dir" );
543- NativeImage .agentBuild (javaHome , userDirStr == null ? null : Paths .get (userDirStr ), buildArgs );
544- return 0 ;
545- }
546-
547493 private static String transformPath (String path ) {
548494 String result = path ;
549495 if (result .contains ("{pid}" )) {
0 commit comments