< prev index next >
src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactory.java
Print this page
*** 88,103 ****
this.types = new HashMap<>();
this.libraryNames = ctx.options.libraryNames;
this.libraryPaths = ctx.options.recordLibraryPath? ctx.options.libraryPaths : null;
this.noNativeLocations = ctx.options.noNativeLocations;
this.global_jsb = new JavaSourceBuilder();
! this.srcDir = Paths.get(ctx.options.srcDumpDir)
! .resolve(headerFile.pkgName.replace('.', File.separatorChar));
}
// main entry point that generates & saves .java files for the header file
! public void generate(List<Tree> decls) {
global_jsb.addPackagePrefix(headerFile.pkgName);
Map<String, Object> header = new HashMap<>();
header.put("path", headerFile.path.toAbsolutePath().toString());
if (!libraryNames.isEmpty()) {
--- 88,104 ----
this.types = new HashMap<>();
this.libraryNames = ctx.options.libraryNames;
this.libraryPaths = ctx.options.recordLibraryPath? ctx.options.libraryPaths : null;
this.noNativeLocations = ctx.options.noNativeLocations;
this.global_jsb = new JavaSourceBuilder();
! this.srcDir = ctx.options.srcDumpDir != null?
! Paths.get(ctx.options.srcDumpDir).resolve(headerFile.pkgName.replace('.', File.separatorChar)) :
! null;
}
// main entry point that generates & saves .java files for the header file
! public Map<String, String> generate(List<Tree> decls) {
global_jsb.addPackagePrefix(headerFile.pkgName);
Map<String, Object> header = new HashMap<>();
header.put("path", headerFile.path.toAbsolutePath().toString());
if (!libraryNames.isEmpty()) {
*** 139,157 ****
--- 140,164 ----
global_jsb.addNestedType(jsb);
}
global_jsb.interfaceEnd();
String src = global_jsb.build();
+ if (srcDir != null) {
try {
Files.createDirectories(srcDir);
Path srcPath = srcDir.resolve(clsName + ".java");
Files.write(srcPath, List.of(src));
} catch (Exception ex) {
handleException(ex);
}
}
+ Map<String, String> srcMap = new HashMap<>();
+ srcMap.put(headerClassName, src);
+ return srcMap;
+ }
+
protected void handleException(Exception ex) {
log.printError("cannot.write.class.file", headerFile.pkgName + "." + headerFile.headerClsName, ex);
log.printStackTrace(ex);
}
< prev index next >