< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactory.java

Print this page




 151     }
 152 
 153     protected void handleException(Exception ex) {
 154         log.printError("cannot.write.class.file", headerFile.pkgName + "." + headerFile.headerClsName, ex);
 155         log.printStackTrace(ex);
 156     }
 157 
 158     private void addNativeLocation(JavaSourceBuilder jsb, Tree tree) {
 159         addNativeLocation(jsb, tree.location());
 160     }
 161 
 162     private void addNativeLocation(JavaSourceBuilder jsb, SourceLocation src) {
 163         addNativeLocation(true, jsb, src);
 164     }
 165 
 166     private void addNativeLocation(boolean align, JavaSourceBuilder jsb, SourceLocation src) {
 167         if (! noNativeLocations) {
 168             SourceLocation.Location loc = src.getFileLocation();
 169             Path p = loc.path();
 170             Map<String, Object> fields = new HashMap<>();
 171             fields.put("file", p == null ? "builtin" :  p.toAbsolutePath().toString().replace("\\", "\\\\"));
 172             fields.put("line", loc.line());
 173             fields.put("column", loc.column());
 174             jsb.addAnnotation(align, NATIVE_LOCATION, fields);
 175         }
 176     }
 177 
 178     private void addClassIfNeeded(String clsName, JavaSourceBuilder jsb) {
 179         if (null != types.put(clsName, jsb)) {
 180             log.printWarning("warn.class.overwritten", clsName);
 181         }
 182     }
 183 
 184     private static boolean isBitField(Tree tree) {
 185         return tree instanceof FieldTree && ((FieldTree)tree).isBitField();
 186     }
 187 
 188     /**
 189      *
 190      * @param jsb JavaSourceBuilder for the struct
 191      * @param tree The Tree




 151     }
 152 
 153     protected void handleException(Exception ex) {
 154         log.printError("cannot.write.class.file", headerFile.pkgName + "." + headerFile.headerClsName, ex);
 155         log.printStackTrace(ex);
 156     }
 157 
 158     private void addNativeLocation(JavaSourceBuilder jsb, Tree tree) {
 159         addNativeLocation(jsb, tree.location());
 160     }
 161 
 162     private void addNativeLocation(JavaSourceBuilder jsb, SourceLocation src) {
 163         addNativeLocation(true, jsb, src);
 164     }
 165 
 166     private void addNativeLocation(boolean align, JavaSourceBuilder jsb, SourceLocation src) {
 167         if (! noNativeLocations) {
 168             SourceLocation.Location loc = src.getFileLocation();
 169             Path p = loc.path();
 170             Map<String, Object> fields = new HashMap<>();
 171             fields.put("file", p == null ? "<builtin>" :  p.toAbsolutePath().toString().replace("\\", "\\\\"));
 172             fields.put("line", loc.line());
 173             fields.put("column", loc.column());
 174             jsb.addAnnotation(align, NATIVE_LOCATION, fields);
 175         }
 176     }
 177 
 178     private void addClassIfNeeded(String clsName, JavaSourceBuilder jsb) {
 179         if (null != types.put(clsName, jsb)) {
 180             log.printWarning("warn.class.overwritten", clsName);
 181         }
 182     }
 183 
 184     private static boolean isBitField(Tree tree) {
 185         return tree instanceof FieldTree && ((FieldTree)tree).isBitField();
 186     }
 187 
 188     /**
 189      *
 190      * @param jsb JavaSourceBuilder for the struct
 191      * @param tree The Tree


< prev index next >