< prev index next >
src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactory.java
Print this page
*** 66,75 ****
--- 66,82 ----
"Ljava/nicl/metadata/Header;", true);
av.visit("path", owner.path.toAbsolutePath().toString());
av.visitEnd();
}
+ private void handleException(Exception ex) {
+ System.err.println(Main.format("cannot.write.class.file", owner.pkgName + "." + owner.clsName, ex));
+ if (Main.DEBUG) {
+ ex.printStackTrace(System.err);
+ }
+ }
+
private void annotateC(ClassVisitor cw, Cursor dcl) {
AnnotationVisitor av = cw.visitAnnotation(
"Ljava/nicl/metadata/C;", true);
SourceLocation src = dcl.getSourceLocation();
SourceLocation.Location loc = src.getFileLocation();
*** 201,211 ****
.forEachOrdered(cx -> addField(cw, cx, cursor.type()));
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
private void createEnum(Cursor cursor) {
String nativeName = Utils.getIdentifier(cursor);
--- 208,218 ----
.forEachOrdered(cx -> addField(cw, cx, cursor.type()));
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! handleException(ex);
}
}
private void createEnum(Cursor cursor) {
String nativeName = Utils.getIdentifier(cursor);
*** 244,254 ****
.forEachOrdered(cx -> addConstant(cw, cx));
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
private void createAnnotationCls(Cursor dcl) {
String nativeName = Utils.getIdentifier(dcl);
--- 251,261 ----
.forEachOrdered(cx -> addConstant(cw, cx));
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! handleException(ex);
}
}
private void createAnnotationCls(Cursor dcl) {
String nativeName = Utils.getIdentifier(dcl);
*** 283,293 ****
ACC_PUBLIC | ACC_STATIC | ACC_ABSTRACT | ACC_INTERFACE | ACC_ANNOTATION);
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
private void createFunctionalInterface(JType2 jt2) {
JType.FnIf fnif = (JType.FnIf) jt2.getDelegate();
--- 290,300 ----
ACC_PUBLIC | ACC_STATIC | ACC_ABSTRACT | ACC_INTERFACE | ACC_ANNOTATION);
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! handleException(ex);
}
}
private void createFunctionalInterface(JType2 jt2) {
JType.FnIf fnif = (JType.FnIf) jt2.getDelegate();
*** 326,336 ****
mv.visitEnd();
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
private void createFunctionalInterface(Cursor dcl, JType.FnIf fnif) {
JType.Function fn = fnif.getFunction();
--- 333,343 ----
mv.visitEnd();
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! handleException(ex);
}
}
private void createFunctionalInterface(Cursor dcl, JType.FnIf fnif) {
JType.Function fn = fnif.getFunction();
*** 379,389 ****
mv.visitEnd();
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
private void defineType(Cursor dcl, TypeAlias alias) {
if (alias.getAnnotationDescriptor() != null) {
--- 386,396 ----
mv.visitEnd();
// Write class
try {
writeClassFile(cw, owner.clsName + "$" + intf);
} catch (IOException ex) {
! handleException(ex);
}
}
private void defineType(Cursor dcl, TypeAlias alias) {
if (alias.getAnnotationDescriptor() != null) {
*** 470,481 ****
--- 477,490 ----
if (jt instanceof JType2) {
jt2 = (JType2) jt;
jt = jt2.getDelegate();
} else {
logger.warning(() -> "Should have JType2 in addType");
+ if (Main.DEBUG) {
new Throwable().printStackTrace(System.err);
}
+ }
if (cursor == null) {
assert (jt2 != null);
if (jt instanceof JType.FnIf) {
createFunctionalInterface(jt2);
}
*** 508,518 ****
logger.warning(() -> "Unsupported declaration Cursor:");
logger.fine(() -> Printer.Stringifier(p -> p.dumpCursor(cursor, true)));
break;
}
} catch (Exception ex) {
! ex.printStackTrace(System.err);
logger.warning("Cursor causing above exception is: " + cursor.spelling());
logger.fine(() -> Printer.Stringifier(p -> p.dumpCursor(cursor, true)));
}
return this;
}
--- 517,527 ----
logger.warning(() -> "Unsupported declaration Cursor:");
logger.fine(() -> Printer.Stringifier(p -> p.dumpCursor(cursor, true)));
break;
}
} catch (Exception ex) {
! handleException(ex);
logger.warning("Cursor causing above exception is: " + cursor.spelling());
logger.fine(() -> Printer.Stringifier(p -> p.dumpCursor(cursor, true)));
}
return this;
}
*** 692,702 ****
@Override
protected void produce() {
try {
writeClassFile(global_cw, owner.clsName);
} catch (IOException ex) {
! ex.printStackTrace(System.err);
}
}
@Override
protected Map<String, byte[]> collect() {
--- 701,711 ----
@Override
protected void produce() {
try {
writeClassFile(global_cw, owner.clsName);
} catch (IOException ex) {
! handleException(ex);
}
}
@Override
protected Map<String, byte[]> collect() {
< prev index next >