aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-03-31 16:08:54 +0200
committerMichael Bien <[email protected]>2010-03-31 16:08:54 +0200
commit2fe517b9a2e1a680b50c7e1273897495800c5350 (patch)
treec39ed5cbb48d49a34f024437e5dbfe76ff29c447 /src/java/com/sun/gluegen/JavaEmitter.java
parentf76e3bb1cff43d35b6884c17418ea20cd4ed5e22 (diff)
implemented better logging using java.util.logging.
Diffstat (limited to 'src/java/com/sun/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index 25aeb16..4e154d7 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -39,11 +39,20 @@
package com.sun.gluegen;
+import java.beans.PropertyChangeEvent;
import java.io.*;
import java.util.*;
import java.text.MessageFormat;
import com.sun.gluegen.cgram.types.*;
+import java.beans.PropertyChangeListener;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Filter;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import javax.swing.plaf.basic.BasicComboBoxUI.PropertyChangeHandler;
+import static java.util.logging.Level.*;
// PROBLEMS:
// - what if something returns 'const int *'? Could we
@@ -89,6 +98,8 @@ public class JavaEmitter implements GlueEmitter {
private MachineDescription machDesc32;
private MachineDescription machDesc64;
+ protected final static Logger LOG = Logger.getLogger(JavaEmitter.class.getPackage().getName());
+
public void readConfigurationFile(String filename) throws Exception {
cfg = createConfig();
cfg.read(filename);
@@ -406,16 +417,10 @@ public class JavaEmitter implements GlueEmitter {
ArrayList<FunctionSymbol> funcsToBind = new ArrayList<FunctionSymbol>(funcsToBindSet);
// sort functions to make them easier to find in native code
- Collections.sort(
- funcsToBind,
- new Comparator<FunctionSymbol>() {
- public int compare(FunctionSymbol o1, FunctionSymbol o2) {
- return o1.getName().compareTo(o2.getName());
- }
- @Override
- public boolean equals(Object obj) {
- return obj.getClass() == this.getClass();
- }
+ Collections.sort(funcsToBind, new Comparator<FunctionSymbol>() {
+ public int compare(FunctionSymbol o1, FunctionSymbol o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
});
// Bind all the C funcs to Java methods
@@ -787,7 +792,7 @@ public class JavaEmitter implements GlueEmitter {
}
if (name == null) {
- System.err.println("WARNING: skipping emission of unnamed struct \"" + structType + "\"");
+ LOG.log(WARNING, "skipping emission of unnamed struct \"{0}\"", structType);
return;
}
@@ -851,7 +856,6 @@ public class JavaEmitter implements GlueEmitter {
String structClassPkg = cfg.packageForStruct(name);
PrintWriter writer = null;
- PrintWriter cWriter = null;
try {
writer = openFile(
cfg.javaOutputDir() + File.separator +
@@ -863,9 +867,9 @@ public class JavaEmitter implements GlueEmitter {
if (cfg.nativeOutputUsesJavaHierarchy()) {
nRoot += File.separator + CodeGenUtils.packageAsPath(cfg.packageName());
}
- cWriter = openFile(nRoot + File.separator + containingTypeName + "_JNI.c");
- CodeGenUtils.emitAutogeneratedWarning(cWriter, this);
- emitCHeader(cWriter, containingTypeName);
+ PrintWriter newCWriter = openFile(nRoot + File.separator + containingTypeName + "_JNI.c");
+ CodeGenUtils.emitAutogeneratedWarning(newCWriter, this);
+ emitCHeader(newCWriter, containingTypeName);
}
} catch(Exception e) {
throw new RuntimeException("Unable to open files for emission of struct class", e);
@@ -1095,7 +1099,6 @@ public class JavaEmitter implements GlueEmitter {
} catch (Exception e) {
System.err.println("Error occurred while creating accessor for field \"" +
field.getName() + "\" in type \"" + name + "\"");
- e.printStackTrace();
throw(e);
}
if (externalJavaType.isPrimitive()) {
@@ -1152,8 +1155,7 @@ public class JavaEmitter implements GlueEmitter {
}
} else {
// FIXME
- System.err.println("WARNING: Complicated fields (field \"" + field + "\" of type \"" + name +
- "\") not implemented yet");
+ LOG.log(WARNING, "Complicated fields (field \"{0}\" of type \"{1}\") not implemented yet", new Object[]{field, name});
// throw new RuntimeException("Complicated fields (field \"" + field + "\" of type \"" + t +
// "\") not implemented yet");
}
@@ -1240,7 +1242,7 @@ public class JavaEmitter implements GlueEmitter {
// t is<type>**, targetType is <type>*, we need to get <type>
Type bottomType = targetType.asPointer().getTargetType();
- System.out.println("INFO: Opaque Type: "+t+", targetType: "+targetType+", bottomType: "+bottomType+" is ptr-ptr");
+ LOG.log(INFO, "Opaque Type: {0}, targetType: {1}, bottomType: {2} is ptr-ptr", new Object[]{t, targetType, bottomType});
}
}
}
@@ -1333,7 +1335,7 @@ public class JavaEmitter implements GlueEmitter {
} else {
// t is<type>[][], targetType is <type>[], we need to get <type>
bottomType = targetType.asArray().getElementType();
- System.out.println("WARNING: typeToJavaType(ptr-ptr): "+t+", targetType: "+targetType+", bottomType: "+bottomType+" -> Unhandled!");
+ LOG.log(WARNING, "typeToJavaType(ptr-ptr): {0}, targetType: {1}, bottomType: {2} -> Unhandled!", new Object[]{t, targetType, bottomType});
}
// Warning: The below code is not backed up by an implementation,
@@ -1569,7 +1571,7 @@ public class JavaEmitter implements GlueEmitter {
*/
protected void emitCustomJavaCode(PrintWriter writer, String className) throws Exception {
List<String> code = cfg.customJavaCodeForClass(className);
- if (code.size() == 0)
+ if (code.isEmpty())
return;
writer.println();