3131import java .io .IOException ;
3232import java .io .InputStream ;
3333import java .io .InputStreamReader ;
34+ import java .io .PrintStream ;
3435import java .lang .module .FindException ;
3536import java .lang .module .ModuleDescriptor ;
3637import java .lang .module .ModuleFinder ;
8384import com .oracle .svm .common .option .CommonOptions ;
8485import com .oracle .svm .core .FallbackExecutor ;
8586import com .oracle .svm .core .FallbackExecutor .Options ;
87+ import com .oracle .svm .core .JavaVersionUtil ;
8688import com .oracle .svm .core .NativeImageClassLoaderOptions ;
8789import com .oracle .svm .core .OS ;
8890import com .oracle .svm .core .SharedConstants ;
111113import com .oracle .svm .util .StringUtil ;
112114
113115import jdk .graal .compiler .options .OptionKey ;
114- import com .oracle .svm .core .JavaVersionUtil ;
115116import jdk .internal .jimage .ImageReader ;
116117
117118public class NativeImage {
@@ -1865,7 +1866,17 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
18651866
18661867 Process p = null ;
18671868 try {
1868- p = pb .inheritIO ().start ();
1869+ if (!useBundle ()) {
1870+ pb .inheritIO ();
1871+ }
1872+ p = pb .start ();
1873+ if (useBundle ()) {
1874+ var internalOutputDir = bundleSupport .outputDir .toString ();
1875+ var externalOutputDir = bundleSupport .getExternalOutputDir ().toString ();
1876+ Function <String , String > filter = line -> line .replace (internalOutputDir , externalOutputDir );
1877+ ProcessOutputTransformer .attach (p .getInputStream (), filter , System .out );
1878+ ProcessOutputTransformer .attach (p .getErrorStream (), filter , System .err );
1879+ }
18691880 imageBuilderPid = p .pid ();
18701881 return p .waitFor ();
18711882 } catch (IOException | InterruptedException e ) {
@@ -1877,6 +1888,22 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
18771888 }
18781889 }
18791890
1891+ private record ProcessOutputTransformer (InputStream in , Function <String , String > filter , PrintStream out ) implements Runnable {
1892+
1893+ static void attach (InputStream in , Function <String , String > filter , PrintStream out ) {
1894+ Thread .ofVirtual ().start (new ProcessOutputTransformer (in , filter , out ));
1895+ }
1896+
1897+ @ Override
1898+ public void run () {
1899+ try (BufferedReader reader = new BufferedReader (new InputStreamReader (in ))) {
1900+ reader .lines ().map (filter ).forEach (out ::println );
1901+ } catch (IOException e ) {
1902+ throw showError ("Unable to process stdout/stderr of image builder process" , e );
1903+ }
1904+ }
1905+ }
1906+
18801907 /**
18811908 * Creates a file with name 'fileName' in the {@link NativeImage#driverTempDir temporary
18821909 * directory} and returns the path to the newly created file. Note: the file will be deleted if
0 commit comments