31
31
import java .io .IOException ;
32
32
import java .io .InputStream ;
33
33
import java .io .InputStreamReader ;
34
+ import java .io .PrintStream ;
34
35
import java .lang .module .FindException ;
35
36
import java .lang .module .ModuleDescriptor ;
36
37
import java .lang .module .ModuleFinder ;
83
84
import com .oracle .svm .common .option .CommonOptions ;
84
85
import com .oracle .svm .core .FallbackExecutor ;
85
86
import com .oracle .svm .core .FallbackExecutor .Options ;
87
+ import com .oracle .svm .core .JavaVersionUtil ;
86
88
import com .oracle .svm .core .NativeImageClassLoaderOptions ;
87
89
import com .oracle .svm .core .OS ;
88
90
import com .oracle .svm .core .SharedConstants ;
111
113
import com .oracle .svm .util .StringUtil ;
112
114
113
115
import jdk .graal .compiler .options .OptionKey ;
114
- import com .oracle .svm .core .JavaVersionUtil ;
115
116
import jdk .internal .jimage .ImageReader ;
116
117
117
118
public class NativeImage {
@@ -1865,7 +1866,17 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
1865
1866
1866
1867
Process p = null ;
1867
1868
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
+ }
1869
1880
imageBuilderPid = p .pid ();
1870
1881
return p .waitFor ();
1871
1882
} catch (IOException | InterruptedException e ) {
@@ -1877,6 +1888,22 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
1877
1888
}
1878
1889
}
1879
1890
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
+
1880
1907
/**
1881
1908
* Creates a file with name 'fileName' in the {@link NativeImage#driverTempDir temporary
1882
1909
* directory} and returns the path to the newly created file. Note: the file will be deleted if
0 commit comments