Index: /trunk/ProjectFortress/src/com/sun/fortress/repository/ProjectProperties.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/repository/ProjectProperties.java (revision 3040)
+++ /trunk/ProjectFortress/src/com/sun/fortress/repository/ProjectProperties.java (revision 3290)
@@ -1,4 +1,4 @@
 /*******************************************************************************
-    Copyright 2008 Sun Microsystems, Inc.,
+    Copyright 2009 Sun Microsystems, Inc.,
     4150 Network Circle, Santa Clara, California 95054, U.S.A.
     All rights reserved.
@@ -248,5 +248,6 @@
     public static final String ANALYZED_CACHE_DIR = get("fortress.analyzed.cache", "${CACHES}/analyzed_cache");
     public static final String SYNTAX_CACHE_DIR = get("fortress.syntax.cache", "${CACHES}/syntax_cache");
-    public static final String BYTECODE_CACHE_DIR = get("fortress.syntax.cache", "${CACHES}/bytecode_cache");    
+    public static final String BYTECODE_CACHE_DIR = get("fortress.bytecode.cache", "${CACHES}/bytecode_cache");    
+    public static final String NATIVE_WRAPPER_CACHE_DIR = get("fortress.nativewrapper.cache", "${CACHES}/nativewrapper_cache");    
 
     public static final Path SOURCE_PATH = new Path(searchDef("fortress.source.path", "FORTRESS_SOURCE_PATH", "."));
@@ -259,4 +260,5 @@
         ensureDirectoryExists(SYNTAX_CACHE_DIR);
         ensureDirectoryExists(BYTECODE_CACHE_DIR);
+        ensureDirectoryExists(NATIVE_WRAPPER_CACHE_DIR);
     }
 
Index: /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/TransactionJUTest.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/TransactionJUTest.java (revision 2449)
+++ /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/TransactionJUTest.java (revision 3290)
@@ -1,4 +1,4 @@
 /*******************************************************************************
-    Copyright 2008 Sun Microsystems, Inc.,
+    Copyright 2009 Sun Microsystems, Inc.,
     4150 Network Circle, Santa Clara, California 95054, U.S.A.
     All rights reserved.
@@ -14,5 +14,5 @@
     Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
     trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- ******************************************************************************/
+******************************************************************************/
 
 package com.sun.fortress.tests.unit_tests;
@@ -24,15 +24,15 @@
 public class TransactionJUTest extends TestCaseWrapper {
     public TransactionJUTest(String testName) {
- super(testName);
+        super(testName);
     }
     public TransactionJUTest() {
- super("TransactionTest");
+        super("TransactionTest");
     }
 
     public void testReadSet() {
- int numThreads = Runtime.getRuntime().availableProcessors();
- FortressTaskRunnerGroup group = new FortressTaskRunnerGroup(numThreads);
- TestTask task = new TestTask();
- group.invoke(task);
+        int numThreads = Runtime.getRuntime().availableProcessors();
+        FortressTaskRunnerGroup group = new FortressTaskRunnerGroup(numThreads);
+        TestTask task = new TestTask();
+        group.invoke(task);
     }
 }
Index: /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/WrapperGeneratorJUTest.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/WrapperGeneratorJUTest.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/WrapperGeneratorJUTest.java (revision 3290)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+******************************************************************************/
+
+package com.sun.fortress.tests.unit_tests;
+
+import java.lang.reflect.Method;
+import java.util.*;
+import org.objectweb.asm.*;
+
+import com.sun.fortress.interpreter.evaluator.values.*;
+import com.sun.fortress.useful.TestCaseWrapper;
+import com.sun.fortress.compiler.nativeInterface.*;
+
+public class WrapperGeneratorJUTest extends TestCaseWrapper {
+    public WrapperGeneratorJUTest(String testName) {
+        super(testName);
+    }
+    public WrapperGeneratorJUTest() {
+        super("WrapperGeneratorTest");
+    }
+
+    public void testPrintln() {
+        MyClassLoader loader = new MyClassLoader();
+        Class c = FortressTransformer.transform(loader, "com.sun.fortress.nativeHelpers.simplePrintln");
+        Class[] parameterTypes = new Class[1];
+        try {
+            parameterTypes[0] = Class.forName("com.sun.fortress.interpreter.evaluator.values.FString"); 
+            Method m = c.getMethod("println", parameterTypes);
+            FString foo = FString.make("fa la la");
+            m.invoke(null, foo);
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+}
Index: /trunk/ProjectFortress/src/com/sun/fortress/nativeHelpers/simplePrintln.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/nativeHelpers/simplePrintln.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/nativeHelpers/simplePrintln.java (revision 3290)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************/
+
+package com.sun.fortress.nativeHelpers;
+
+public class simplePrintln {
+	
+	public static void println(String s) {
+		System.out.println(s);
+	}
+
+}
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/MyClassLoader.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/MyClassLoader.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/MyClassLoader.java (revision 3290)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+  Copyright 2009 Sun Microsystems, Inc.,
+  4150 Network Circle, Santa Clara, California 95054, U.S.A.
+  All rights reserved.
+
+  U.S. Government Rights - Commercial software.
+  Government users are subject to the Sun Microsystems, Inc. standard
+  license agreement and applicable provisions of the FAR and its supplements.
+
+  Use is subject to license terms.
+
+  This distribution may include materials developed by third parties.
+
+  Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+  trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+******************************************************************************/
+
+package com.sun.fortress.compiler.nativeInterface;
+
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import com.sun.fortress.repository.ProjectProperties;
+
+public class MyClassLoader extends ClassLoader {
+    
+    String repository = ProjectProperties.NATIVE_WRAPPER_CACHE_DIR;
+
+    public MyClassLoader() {
+        // TODO Auto-generated constructor stub
+    }
+
+    public MyClassLoader(ClassLoader parent) {
+        super(parent);
+        // TODO Auto-generated constructor stub
+    }
+    
+    public Class defineClass(String name, byte[] b) {
+        return defineClass(name, b, 0, b.length);
+    }
+    public static String mangle(String s ) {
+        return s;
+    }
+    
+    @SuppressWarnings("unchecked")
+        public Class findClass(String name) {
+        String n = mangle(name);
+        
+        byte[] b;
+        Class result = null;
+        try {
+            FileInputStream in = new FileInputStream( repository + n + ".class");
+            int l = in.available();
+            b = new byte[l];
+            in.read(b);
+            result = defineClass(name, b, 0, l);
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+        return result;
+    }
+    
+    public void writeClass(String name, byte[] bytes) {
+        String n = mangle(name);
+        try {
+            FileOutputStream out = new FileOutputStream(repository + n + ".class");
+            out.write(bytes);
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+}
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressMethodAdapter.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressMethodAdapter.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressMethodAdapter.java (revision 3290)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+  Copyright 2009 Sun Microsystems, Inc.,
+  4150 Network Circle, Santa Clara, California 95054, U.S.A.
+  All rights reserved.
+
+  U.S. Government Rights - Commercial software.
+  Government users are subject to the Sun Microsystems, Inc. standard
+  license agreement and applicable provisions of the FAR and its supplements.
+
+  Use is subject to license terms.
+
+  This distribution may include materials developed by third parties.
+
+  Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+  trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+******************************************************************************/
+
+package com.sun.fortress.compiler.nativeInterface;
+import java.util.*;
+
+import org.objectweb.asm.*;
+
+import com.sun.fortress.interpreter.evaluator.values.FString;
+import com.sun.fortress.interpreter.evaluator.values.FInt;
+import com.sun.fortress.interpreter.evaluator.values.FLong;
+
+
+public class FortressMethodAdapter extends ClassAdapter {
+
+    String className = "temp";
+    private final String prefix = "com/sun/fortress/interpreter/evaluator/values/";
+
+    public FortressMethodAdapter(ClassVisitor cv) {
+        super(cv);
+    }
+
+    public void visit(int version, int access, String name, String signature, 
+                      String superName, String[] interfaces) {
+        cv.visit(version, access, name, signature, superName, interfaces);
+        className = name;
+    }
+
+    public MethodVisitor visitMethod(int access, 
+                                     String name, String desc, 
+                                     String signature, String[] exceptions) {
+        if (!name.equals("<init>")) {
+            generateNewBody(access, desc, signature, exceptions, name, name);
+        }
+        return super.visitMethod(access, name, desc, signature, exceptions);
+    }
+
+    private void generateNewBody(int access,
+                                 String desc, String signature,
+                                 String[] exceptions,
+                                 String name, String newName) {
+
+        SignatureParser sp = new SignatureParser(desc);
+        MethodVisitor mv = cv.visitMethod(access, name, 
+                                          sp.getFortressifiedSignature(), 
+                                          signature, exceptions);
+        mv.visitCode();
+        Label l0 = new Label();
+        mv.visitLabel(l0);
+        int count = 0;
+        List<String> args = sp.getFortressArguments();
+        for (String s : args) {
+            mv.visitVarInsn(Opcodes.ALOAD, count++);
+            if (s.equals("L" + prefix + "FString;")) {
+                mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, prefix + "FString", "toString", 
+                                   "()Ljava/lang/String;");
+            } else if (s.equals("L" + prefix + "FLong")) {
+                mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, prefix + "FLong", "toLong",
+                                   "()J");
+            } else if (s.equals("L" + prefix + "FInt;")) {
+                mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, prefix + "FInt", "toInt",
+                                   "()I");
+            }
+        }
+        mv.visitMethodInsn(Opcodes.INVOKESTATIC, 
+                           className,
+                           name,
+                           sp.getSignature());
+
+        //     mv.visitVarInsn(Opcodes.LSTORE, count);
+        if (sp.getFortressResult().equals("L" + prefix + "FString;")) 
+            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, prefix + "FString", 
+                               "<init>", "(Ljava/lang/String;)LFString;");
+        else if (sp.getFortressResult().equals("L" + prefix + "FLong;"))
+            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, prefix + "FLong",
+                               "<init>", "(J)LFLong;");
+        else if (sp.getFortressResult().equals("L" + prefix + "FInt;"))
+            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "FInt",
+                               "<init>", "(I)LFInt;");
+        else if (sp.getFortressResult().equals("L" + prefix + "FVoid;")) {
+            mv.visitFieldInsn(Opcodes.GETSTATIC, prefix + "FVoid",
+                              "V", "L" + prefix + "FVoid;");
+        }
+        mv.visitInsn(Opcodes.ARETURN);
+        mv.visitMaxs(2,1);
+        mv.visitEnd();
+    }
+
+    public void visitEnd() {
+        super.visitEnd();
+    }
+}
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressTransformer.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressTransformer.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressTransformer.java (revision 3290)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+  Copyright 2009 Sun Microsystems, Inc.,
+  4150 Network Circle, Santa Clara, California 95054, U.S.A.
+  All rights reserved.
+
+  U.S. Government Rights - Commercial software.
+  Government users are subject to the Sun Microsystems, Inc. standard
+  license agreement and applicable provisions of the FAR and its supplements.
+
+  Use is subject to license terms.
+
+  This distribution may include materials developed by third parties.
+
+  Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+  trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+******************************************************************************/
+
+package com.sun.fortress.compiler.nativeInterface;
+
+import java.lang.reflect.Method;
+import java.io.FileOutputStream;
+import org.objectweb.asm.*;
+
+public class FortressTransformer {
+    @SuppressWarnings("unchecked")
+
+    
+        public static Class transform(MyClassLoader loader, String fileName) {
+        Class result = null;
+        try {
+            ClassReader cr = new ClassReader(fileName);
+            ClassWriter cw = new ClassWriter(1);
+            FortressMethodAdapter fa = new FortressMethodAdapter(cw);
+            cr.accept(fa, 0);
+            byte[] b2 = cw.toByteArray();
+            loader.writeClass(fileName, b2);
+            Class c = loader.findClass(fileName);
+            result = c;
+             
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }  
+        return result;
+    }
+        
+}
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/SignatureParser.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/SignatureParser.java (revision 3290)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/SignatureParser.java (revision 3290)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+******************************************************************************/
+package com.sun.fortress.compiler.nativeInterface;
+
+import com.sun.fortress.interpreter.evaluator.values.FString;
+import com.sun.fortress.interpreter.evaluator.values.FInt;
+import com.sun.fortress.interpreter.evaluator.values.FLong;
+import com.sun.fortress.interpreter.evaluator.values.FChar;
+import com.sun.fortress.interpreter.evaluator.values.FFloat;
+import com.sun.fortress.interpreter.evaluator.values.FBool;
+
+/* This only handles some base types and strings.  We need to beef it up. */
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public class SignatureParser {
+    private List<String> arguments;
+    private List<String> fortressArguments;
+    private String result;
+    private String fortressResult;
+    private String signature;
+
+    private final String prefix = "com/sun/fortress/interpreter/evaluator/values/";
+
+        
+    // For now only one dimensional arrays
+    SignatureParser(String s) {
+        arguments = new ArrayList<String>();
+        fortressArguments = new ArrayList<String>();
+        signature = s;
+
+        if (s.charAt(0) != '(') error(s);
+        int index = 1;
+        int ch = s.charAt(index);
+
+        while (ch != ')') {
+            switch(ch) {
+            case 'B': error(s);
+            case 'S': error(s);
+            case '[': error(s);
+            case 'D': error(s);
+            case 'C': 
+                arguments.add("C"); 
+                fortressArguments.add("L" + prefix + "FChar;");    
+                index++; break;
+            case 'F': 
+                arguments.add("F"); 
+                fortressArguments.add("L" + prefix + "FFloat;");  
+                index++; 
+                break;
+            case 'I': 
+                arguments.add("I"); 
+                fortressArguments.add("L" + prefix + "FInt;");    
+                index++; 
+                break;
+            case 'J': 
+                arguments.add("J"); 
+                fortressArguments.add("L" + prefix + "FLong;");    
+                index++; 
+                break;
+            case 'Z': 
+                arguments.add("Z"); 
+                fortressArguments.add("L" + prefix + "FBool;"); 
+                index++;
+                break;
+            case 'L': 
+                int end = s.indexOf(';', index) + 1;
+                String javaType = s.substring(index, end);
+                arguments.add(javaType);
+                if (javaType.equals("Ljava/lang/String;")) {
+                    fortressArguments.add("L" + prefix + "FString;");
+                    index = end;
+                } else {
+                    error(s);
+                }
+                break;
+            default: error(s);
+            }
+            ch = s.charAt(index);
+        }
+
+        index++;
+        ch = s.charAt(index);
+
+        switch(ch) {
+        case 'B': error(s);
+        case 'S': error(s);
+        case '[': error(s);
+        case 'D': error(s);
+        case 'V': result = "V"; fortressResult = "L" + prefix + "FVoid;";    break;
+        case 'C': result = "C"; fortressResult = "L" + prefix + "FChar;";    break;
+        case 'F': result = "F"; fortressResult = "L" + prefix + "FFloat;";   break;
+        case 'I': result = "I"; fortressResult = "L" + prefix + "FInt;";     break;
+        case 'J': result = "J"; fortressResult = "L" + prefix + "FLong;";    break;
+        case 'Z': result = "Z"; fortressResult = "L" + prefix + "FBool;";    break;
+        case 'L': 
+            int end = s.indexOf(';', index ) + 1;
+            String javaType = s.substring(index, end);
+            result = javaType;
+            if (javaType.equals("Ljava/lang/String;")) {
+                fortressResult = "L" + prefix + "FString;";
+            } else {
+                error(s);
+            }
+            break;
+        default: error(s);
+        }
+    }
+
+    List<String> getArguments() { return arguments;}
+    List<String> getFortressArguments() { return fortressArguments;}
+    String getResult() {return result;}
+    String getFortressResult() {return fortressResult;}
+
+    String getFortressifiedSignature() {
+        String result = "(";
+        // Don't forget the commas"
+        for (String s : fortressArguments) 
+            result = result + s;
+        result = result + ")" + fortressResult;
+        return result;
+    }
+        
+    String getSignature() {
+        return signature;
+    }
+
+    void error(String s) {throw new RuntimeException("Bad Signature " + s);}
+
+}
