Index: kernel/src/main/java/java/lang/Runtime.java
===================================================================
--- kernel/src/main/java/java/lang/Runtime.java (revision 378507)
+++ kernel/src/main/java/java/lang/Runtime.java (working copy)
@@ -157,6 +157,7 @@
* @see SecurityManager#checkExit
*/
public void exit(int code) {
+ VMRuntime.exit(code);
return;
}
@@ -166,7 +167,8 @@
*
*/
public long freeMemory() {
- return 0L;
+ long ll = VMRuntime.freeMemory();
+ return ll;
};
/**
@@ -175,6 +177,7 @@
*
*/
public void gc() {
+ VMRuntime.gc();
return;
};
@@ -198,6 +201,7 @@
* if the library was not allowed to be loaded
*/
public void load(String pathName) {
+ VMRuntime.nativeLoad(pathName, ClassLoader.systemClassLoader);
return;
}
@@ -221,6 +225,7 @@
*
*/
public void runFinalization() {
+ VMRuntime.runFinalization();
return;
};
@@ -234,6 +239,7 @@
* @deprecated This method is unsafe.
*/
public static void runFinalizersOnExit(boolean run) {
+ VMRuntime.runFinalizersOnExit(run);
return;
};
@@ -243,7 +249,8 @@
*
*/
public long totalMemory() {
- return 0L;
+ long ll = VMRuntime.totalMemory();
+ return ll;
};
public void traceInstructions(boolean enable) {
@@ -301,6 +308,7 @@
* @see SecurityManager#checkExit
*/
public void halt(int code) {
+ VMRuntime.exit(code);
return;
}
@@ -308,7 +316,7 @@
* Return the number of processors, always at least one.
*/
public int availableProcessors() {
- return 0;
+ return 1;
}
/**
@@ -316,7 +324,8 @@
* Long.MAX_VALUE.
*/
public long maxMemory() {
- return 0L;
+ long ll = VMRuntime.maxMemory();
+ return ll;
}
}
Index: kernel/src/main/java/java/lang/reflect/Method.java
===================================================================
--- kernel/src/main/java/java/lang/reflect/Method.java (revision 378507)
+++ kernel/src/main/java/java/lang/reflect/Method.java (working copy)
@@ -33,6 +33,12 @@
* otherwise
* @see #hashCode
*/
+ Method (Class c1, String s1, int i1)
+ {
+ }
+ Class declaringClass;
+ int slot;
+
public boolean equals(Object object) {
return false;
}
Index: kernel/src/main/java/java/lang/reflect/Field.java
===================================================================
--- kernel/src/main/java/java/lang/reflect/Field.java (revision 378507)
+++ kernel/src/main/java/java/lang/reflect/Field.java (working copy)
@@ -34,9 +34,14 @@
* otherwise
* @see #hashCode
*/
+ Field (Class c1, String s1, int i1)
+ {
+ }
public boolean equals(Object object) {
return false;
}
+ Class declaringClass;
+ int slot;
/**
* Return the value of the field in the specified object. This reproduces
Index: kernel/src/main/java/java/lang/reflect/Constructor.java
===================================================================
--- kernel/src/main/java/java/lang/reflect/Constructor.java (revision 378507)
+++ kernel/src/main/java/java/lang/reflect/Constructor.java (working copy)
@@ -34,6 +34,14 @@
* otherwise
* @see #hashCode
*/
+
+ Constructor(Class c1, int i1)
+ {
+ }
+
+ Class clazz;
+ int slot;
+
public boolean equals(Object object) {
return false;
}
Index: kernel/src/main/java/java/lang/System.java
===================================================================
--- kernel/src/main/java/java/lang/System.java (revision 378507)
+++ kernel/src/main/java/java/lang/System.java (working copy)
@@ -62,14 +62,28 @@
// Initialize all the slots in System on first use.
static {
+ int tt = VMRuntime.nativeLoad("/cygdrive/c/temp2/Harmony/native-src/linux.IA32/luni_scratch_pad_wjw/libzz.a", ClassLoader.systemClassLoader); //wjw
// Fill in the properties from the VM information.
ensureProperties();
// Set up standard in, out, and err.
err = new String.ConsolePrintStream(new BufferedOutputStream(
new FileOutputStream(FileDescriptor.err)));
+ VMSystem.setErr(err); //wjw
+
out = new String.ConsolePrintStream(new BufferedOutputStream(
new FileOutputStream(FileDescriptor.out)));
+ VMSystem.setOut(out); //wjw
+
+ int xx;
+ for (xx = 0; xx < 100; xx++)
+ {
+ // the below is a test that verifies System.out is initialized properly
+ out.write(0x41); out.write(0x42); out.write(0x43);
+ }
+
in = new BufferedInputStream(new FileInputStream(FileDescriptor.in));
+ VMSystem.setIn(in); //wjw
+
}
/**
@@ -80,8 +94,10 @@
* the new value for in.
*/
public static void setIn(InputStream newIn) {
- SecurityManager secMgr = System.getSecurityManager();
- setFieldImpl("in", newIn);
+ //SecurityManager secMgr = System.getSecurityManager();
+ //setFieldImpl("in", newIn);
+ //wjw fixit -- security is hacked out for now
+ VMSystem.setIn(newIn);
}
/**
@@ -92,9 +108,10 @@
* the new value for out.
*/
public static void setOut(java.io.PrintStream newOut) {
- SecurityManager secMgr = System.getSecurityManager();
-
- setFieldImpl("out", newOut);
+ //SecurityManager secMgr = System.getSecurityManager();
+ //setFieldImpl("out", newOut);
+ //wjw fixit -- security is hacked out for now
+ VMSystem.setOut(newOut);
}
/**
@@ -105,7 +122,9 @@
* the new value for err.
*/
public static void setErr(java.io.PrintStream newErr) {
- SecurityManager secMgr = System.getSecurityManager();
+ //SecurityManager secMgr = System.getSecurityManager();
+ //wjw fixit -- security is hacked out for now
+ VMSystem.setErr(newErr);
}
@@ -533,7 +552,7 @@
* @see SecurityManager#checkExit
*/
public static void exit(int code) {
- RUNTIME.exit(code);
+ VMRuntime.exit(code);
}
/**
@@ -541,7 +560,7 @@
* available memory. Note that, this is a hint only.
*/
public static void gc() {
- RUNTIME.gc();
+ VMRuntime.gc();
}
/**
@@ -553,14 +572,18 @@
* @deprecated Use System.getProperty()
*/
public static String getenv(String var) {
+ //System.out.println("System.getenv() --- security has been turned off");
if (var == null) {
throw new NullPointerException();
}
+ /* fixit -- hack out security for now
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
secMgr.checkPermission(new RuntimePermission("getenv." + var));
}
throw new Error();
+ */
+ return null;
}
/**
@@ -573,10 +596,13 @@
* @return the system properties
*/
public static Properties getProperties() {
+ //System.out.println("System.getProperties() -- security has been turned off");
+ /* fixit -- hack out security for now
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
secMgr.checkPropertiesAccess();
}
+ */
return systemProperties;
}
@@ -587,6 +613,7 @@
* @return the system properties
*/
static Properties internalGetProperties() {
+ //System.out.println("System.internalGetProperties() -- security has been turned off");
return systemProperties;
}
@@ -638,10 +665,12 @@
public static String getProperty(String prop, String defaultValue) {
if (prop.length() == 0)
throw new IllegalArgumentException();
+ /* fixit -- hack out security for now
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
secMgr.checkPropertyAccess(prop);
}
+ */
return systemProperties.getProperty(prop, defaultValue);
}
@@ -657,10 +686,12 @@
public static String setProperty(String prop, String value) {
if (prop.length() == 0)
throw new IllegalArgumentException();
+ /* fixit -- hack out security for now
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
secMgr.checkPermission(new PropertyPermission(prop, "write"));
}
+ */
return (String) systemProperties.setProperty(prop, value);
}
@@ -671,14 +702,25 @@
*
* @return the default values for the system properties.
*/
- private static native String[] getPropertyList();
+ //wjw fixit ----- private static native String[] getPropertyList();
+ private static String[] getPropertyList()
+ {
+ //wjw fixit
+ String[] str = new String[99999];
+ return str;
+ }
/**
* Return the requested encoding. 0 - initialize locale 1 - detected
* platform encoding 2 - command line defined file.encoding 3 - command line
* defined os.encoding
*/
- private static native String getEncoding(int type);
+ //wjw fixit ---- private static native String getEncoding(int type);
+ private static String getEncoding(int type)
+ {
+ String str = "this needs fixing";
+ return str;
+ }
/**
* Answers the active security manager.
@@ -701,7 +743,12 @@
*
* @see java.lang.Object#hashCode
*/
- public static native int identityHashCode(Object anObject);
+ // not the correct interface ---> public static native int identityHashCode(Object anObject);
+ public static int identityHashCode(Object anObject)
+ {
+ int hash = VMSystem.identityHashCode(anObject);
+ return hash;
+ }
/**
* Loads the specified file as a dynamic library.
@@ -710,9 +757,11 @@
* the path of the file to be loaded
*/
public static void load(String pathName) {
+ /*fixit -- hack out security for now
SecurityManager smngr = System.getSecurityManager();
if (smngr != null)
smngr.checkLink(pathName);
+ */
ClassLoader.loadLibraryWithPath(pathName, ClassLoader
.callerClassLoader(), null);
}
@@ -738,7 +787,8 @@
* to perform any outstanding object finalizations.
*/
public static void runFinalization() {
- RUNTIME.runFinalization();
+ //System.out.println("System.runFinalization() has been called");
+ VMRuntime.runFinalization();
}
/**
@@ -752,7 +802,8 @@
* @deprecated This method is unsafe.
*/
public static void runFinalizersOnExit(boolean flag) {
- Runtime.runFinalizersOnExit(flag);
+ //wjw fixit --- looks like "flag" got dropped in the translation
+ VMRuntime.runFinalizersOnExit(flag);
}
/**
@@ -808,7 +859,11 @@
* the name of the library to look up.
* @return the platform specific filename for the library
*/
- public static native String mapLibraryName(String userLibName);
+ //wjw fixit ---- public static native String mapLibraryName(String userLibName);
+ public static String mapLibraryName(String userLibName)
+ {
+ return "System.mapLibraryName() is not implemented";
+ }
/**
* Sets the value of the named static field in the receiver to the passed in
@@ -819,6 +874,10 @@
* @param stream
* the new value of the field
*/
- private static native void setFieldImpl(String fieldName, Object stream);
+ //wjw fixit ---- private static native void setFieldImpl(String fieldName, Object stream);
+ private static void setFieldImpl(String fieldName, Object stream)
+ {
+ return;
+ }
}
Index: kernel/src/main/java/java/lang/ThreadGroup.java
===================================================================
--- kernel/src/main/java/java/lang/ThreadGroup.java (revision 378507)
+++ kernel/src/main/java/java/lang/ThreadGroup.java (working copy)
@@ -32,6 +32,8 @@
*/
public class ThreadGroup {
+
+ static ThreadGroup root; // added for bootstrap.c support
// Name of this ThreadGroup
private String name;
@@ -71,8 +73,8 @@
* Used by the JVM to create the "system" ThreadGroup. Construct a
* ThreadGroup instance, and assign the name "system".
*/
- private ThreadGroup() {
- name = "system";
+ ThreadGroup() {
+ name = "system"; //wjw fixit --- VM specific implementation details should be in VMThread
}
/**
@@ -180,6 +182,10 @@
*
* @see #remove(java.lang.Thread)
*/
+ final void addThread(Thread thread)
+ {
+ add(thread);
+ }
final void add(Thread thread) throws IllegalThreadStateException {
synchronized (this.childrenThreadsLock) {
if (!isDestroyed) {
@@ -521,7 +527,7 @@
*/
public void list() {
// We start in a fresh line
- System.out.println();
+ //System.out.println();
list(0);
}
@@ -535,18 +541,21 @@
*/
private void list(int levels) {
for (int i = 0; i < levels; i++)
- System.out.print(" "); // 4 spaces for each level
-
+ {
+ //System.out.print(" "); // 4 spaces for each level
+ }
// Print the receiver
- System.out.println(this.toString());
+ //System.out.println(this.toString());
// Print the children threads, with 1 extra identation
synchronized (this.childrenThreadsLock) {
for (int i = 0; i < numThreads; i++) {
// children get an extra identation, 4 spaces for each level
for (int j = 0; j <= levels; j++)
- System.out.print(" ");
- System.out.println(this.childrenThreads[i]);
+ {
+ //System.out.print(" ");
+ //System.out.println(this.childrenThreads[i]);
+ }
}
}
synchronized (this.childrenGroupsLock) {
Index: kernel/src/main/java/java/lang/Class.java
===================================================================
--- kernel/src/main/java/java/lang/Class.java (revision 378507)
+++ kernel/src/main/java/java/lang/Class.java (working copy)
@@ -68,6 +69,8 @@
public final class Class implements java.io.Serializable {
private static final long serialVersionUID = 3206093459760846163L;
+ Object vmdata;
+ ProtectionDomain pd;
/**
* Answers a Class object which represents the class named by the argument.
* The name should be the name of a class as described in the class
@@ -82,7 +85,9 @@
* @see java.lang.Class
*/
public static Class forName(String className) throws ClassNotFoundException {
- return null;
+ boolean initializeBoolean = true; //wjw fixit
+ ClassLoader classloader = null; //wjw fixit
+ return VMClass.forName(className, initializeBoolean, classloader);
}
/**
@@ -104,7 +109,9 @@
*/
public static Class forName(String className, boolean initializeBoolean,
ClassLoader classLoader) throws ClassNotFoundException {
- return null;
+ initializeBoolean = true; //wjw fixit
+ ClassLoader classloader = null; //wjw fixit
+ return VMClass.forName(className, initializeBoolean, classloader);
}
/**
@@ -117,7 +124,22 @@
* @see java.lang.Class
*/
public Class[] getClasses() {
- return null;
+ //wjw fixit
+ Class lastClass = this;
+ int xx;
+ for (xx = 0; ; xx++)
+ {
+ lastClass = VMClass.getSuperclass(lastClass);
+ if (lastClass == null) break;
+ }
+ Class [] retArray = new Class[xx + 1];
+ lastClass = this;
+ for (int yy = 0; yy < xx;)
+ {
+ retArray[yy] = lastClass;
+ lastClass = VMClass.getSuperclass(lastClass);
+ }
+ return retArray;
}
/**
@@ -126,6 +148,7 @@
* @throws VerifyError if the Class cannot be verified
*/
void verify() {
+ //wjw fixit
return;
}
@@ -138,7 +161,8 @@
* @see java.lang.ClassLoader
*/
public ClassLoader getClassLoader() {
- return null;
+ //wjw fixit
+ return VMClass.getClassLoader(this);
}
/**
@@ -154,7 +178,8 @@
* @see ClassLoader#isSystemClassLoader()
*/
ClassLoader getClassLoaderImpl() {
- return null;
+ //wjw fixit
+ return VMClass.getClassLoader(this);
};
/**
@@ -166,7 +191,7 @@
* @see java.lang.Class
*/
public Class getComponentType() {
- return null;
+ return VMClass.getComponentType (this);
};
/**
@@ -184,7 +209,23 @@
*/
public Constructor getConstructor(Class parameterTypes[])
throws NoSuchMethodException, SecurityException {
- return null;
+ //wjw fixit
+ boolean publicOnly = true; //fixit -- will setting this to true fill the bill???
+ Constructor[] conArray = VMClass.getDeclaredConstructors(this, publicOnly);
+ for (int ii = 0; ii < conArray.length; ii++)
+ {
+ Class [] ca = conArray[ii].getParameterTypes();
+ int jj;
+ for (jj = 0; jj < ca.length; jj++)
+ {
+ if (parameterTypes[jj] != ca[jj])
+ break;
+ }
+ if (jj == parameterTypes.length) // its an exact match
+ return conArray[jj];
+ }
+ NoSuchMethodException nsme = new NoSuchMethodException();
+ throw nsme;
}
/**
@@ -197,7 +238,8 @@
* @see #getMethods
*/
public Constructor[] getConstructors() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit
+ return VMClass.getDeclaredConstructors(this, publicOnly);
}
/**
@@ -211,7 +253,8 @@
* @see java.lang.Class
*/
public Class[] getDeclaredClasses() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit
+ return VMClass.getDeclaredClasses(this, publicOnly);
}
/**
@@ -229,7 +272,24 @@
*/
public Constructor getDeclaredConstructor(Class parameterTypes[])
throws NoSuchMethodException, SecurityException {
- return null;
+ //wjw fixit
+ boolean publicOnly = true; //fixit -- will setting this to false fill the bill???
+ Constructor[] conArray = VMClass.getDeclaredConstructors(this, publicOnly);
+
+ for (int ii = 0; ii < conArray.length; ii++)
+ {
+ Class [] ca = conArray[ii].getParameterTypes();
+ int jj;
+ for (jj = 0; jj < ca.length; jj++)
+ {
+ if (parameterTypes[jj] != ca[jj])
+ break;
+ }
+ if (jj == parameterTypes.length) // its an exact match
+ return conArray[jj];
+ }
+ NoSuchMethodException nsme = new NoSuchMethodException();
+ throw nsme;
}
/**
@@ -244,7 +304,8 @@
* @see #getMethods
*/
public Constructor[] getDeclaredConstructors() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- true? false??
+ return VMClass.getDeclaredConstructors(this, publicOnly);
}
/**
@@ -263,7 +324,14 @@
*/
public Field getDeclaredField(String name) throws NoSuchFieldException,
SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ Field [] fields = VMClass.getDeclaredFields(this, publicOnly);
+ for (int ii = 0; ii < fields.length; ii++)
+ {
+ if (fields[ii].toString() == name) return fields[ii];
+ }
+ NoSuchFieldException nsfe = new NoSuchFieldException();
+ throw nsfe;
}
/**
@@ -277,7 +345,8 @@
* @see #getFields
*/
public Field[] getDeclaredFields() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ return VMClass.getDeclaredFields(this, publicOnly);
}
/**
@@ -298,7 +367,15 @@
*/
public Method getDeclaredMethod(String name, Class parameterTypes[])
throws NoSuchMethodException, SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ Method [] methods = VMClass.getDeclaredMethods(this, publicOnly);
+ for (int ii = 0; ii < methods.length; ii++)
+ {
+ //wjw fixit oops, need to match on parameterTypes also
+ if (methods[ii].toString() == name) return methods[ii];
+ }
+ NoSuchMethodException nsme = new NoSuchMethodException();
+ throw nsme;
}
/**
@@ -312,7 +389,8 @@
* @see #getMethods
*/
public Method[] getDeclaredMethods() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ return VMClass.getDeclaredMethods(this, publicOnly);
}
/**
@@ -322,7 +400,7 @@
* @return the declaring class of the receiver.
*/
public Class getDeclaringClass() {
- return null;
+ return VMClass.getDeclaringClass(this);
}
/**
@@ -340,7 +418,14 @@
*/
public Field getField(String name) throws NoSuchFieldException,
SecurityException {
- return null;
+ boolean publicOnly = true; //wjw fixit -- is true the right option??
+ Field [] fields = VMClass.getDeclaredFields(this, publicOnly);
+ for (int ii = 0; ii < fields.length; ii++)
+ {
+ if (fields[ii].toString() == name) return fields[ii];
+ }
+ NoSuchFieldException nsfe = new NoSuchFieldException();
+ throw nsfe;
}
/**
@@ -353,7 +438,9 @@
* @see #getDeclaredFields
*/
public Field[] getFields() throws SecurityException {
- return null;
+ boolean publicOnly = true; //wjw fixit -- is true the right option??
+ Field[] fld = VMClass.getDeclaredFields(this, publicOnly);
+ return fld;
}
/**
@@ -363,7 +450,7 @@
* @return Class[] the interfaces the receiver claims to implement.
*/
public Class[] getInterfaces() {
- return null;
+ return VMClass.getInterfaces(this);
};
/**
@@ -383,7 +470,24 @@
*/
public Method getMethod(String name, Class parameterTypes[])
throws NoSuchMethodException, SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ Method [] methods = VMClass.getDeclaredMethods(this, publicOnly);
+ for (int ii = 0; ii < methods.length; ii++)
+ {
+ //wjw fixit oops, need to match on parameterTypes also
+ if (methods[ii].toString() == name)
+ {
+ Class [] paramArray = methods[ii].getParameterTypes();
+ for (int jj = 0; jj < paramArray.length; jj++)
+ {
+ if (paramArray[jj] != parameterTypes[jj])
+ break;
+ }
+ return methods[ii];
+ }
+ }
+ NoSuchMethodException nsme = new NoSuchMethodException();
+ throw nsme;
}
/**
@@ -396,7 +500,8 @@
* @see #getDeclaredMethods
*/
public Method[] getMethods() throws SecurityException {
- return null;
+ boolean publicOnly = false; //wjw fixit -- is false the right option??
+ return VMClass.getDeclaredMethods(this, publicOnly);
}
/**
@@ -408,7 +513,8 @@
* @return the receiver's modifiers
*/
public int getModifiers() {
- return 0;
+ boolean ignoreInnerClassesAttrib = false;
+ return VMClass.getModifiers(this, ignoreInnerClassesAttrib);
};
/**
@@ -420,7 +526,7 @@
* @see java.lang.Class
*/
public String getName() {
- return null;
+ return VMClass.getName(this);
};
/**
@@ -436,6 +542,7 @@
* @see java.lang.Class
*/
public ProtectionDomain getProtectionDomain() {
+ //wjw fixit
return null;
}
@@ -448,6 +555,7 @@
* @see java.lang.Class
*/
ProtectionDomain getPDImpl() {
+ //wjw fixit
return null;
};
@@ -462,6 +570,7 @@
* @see java.lang.ClassLoader
*/
public URL getResource(String resName) {
+ //wjw fixit
return null;
}
@@ -476,6 +585,7 @@
* @see java.lang.ClassLoader
*/
public InputStream getResourceAsStream(String resName) {
+ //wjw fixit
return null;
}
@@ -487,6 +597,7 @@
* @see #getMethods
*/
public Object[] getSigners() {
+ //wjw fixit
return null;
}
@@ -498,7 +609,7 @@
* @return the receiver's superclass.
*/
public Class getSuperclass() {
- return null;
+ return VMClass.getSuperclass(this);
};
/**
@@ -508,7 +619,7 @@
* false if it does not represent an array class
*/
public boolean isArray() {
- return false;
+ return VMClass.isArray(this);
};
/**
@@ -526,7 +637,7 @@
* if the parameter is null
*/
public boolean isAssignableFrom(Class cls) {
- return false;
+ return VMClass.isAssignableFrom(this, cls);
};
/**
@@ -541,7 +652,7 @@
* Object the object to test
*/
public boolean isInstance(Object object) {
- return false;
+ return VMClass.isInstance(this, object);
};
/**
@@ -551,7 +662,7 @@
* false if it does not represent an interface
*/
public boolean isInterface() {
- return false;
+ return VMClass.isInterface(this);
}
/**
@@ -561,7 +672,7 @@
* false if it does not represent a base type
*/
public boolean isPrimitive() {
- return false;
+ return VMClass.isPrimitive(this);
};
/**
@@ -581,6 +692,7 @@
*/
public Object newInstance() throws IllegalAccessException,
InstantiationException {
+ //wjw fixit ---- try using Constructor.newInstance() ?????
return null;
}
@@ -591,7 +703,8 @@
* @return a printable representation for the receiver.
*/
public String toString() {
- return null;
+ //System.out.println("Class.toString() -- not implemented");
+ return this.toString(); /// is this right???????
}
/**
@@ -601,6 +714,7 @@
* @return Package the Package of which this class is a member or null
*/
public Package getPackage() {
+ //wjw fixit
return null;
}
@@ -612,6 +726,7 @@
* @return the assertion status for this class
*/
public boolean desiredAssertionStatus() {
+ //wjw fixit
return false;
}
@@ -649,6 +764,7 @@
* @return the array of the most recent classes on the stack
*/
static final Class[] getStackClasses(int maxDepth, boolean stopAtPrivileged) {
+ //wjw fixit
return null;
};
Index: kernel/src/main/java/java/lang/Object.java
===================================================================
--- kernel/src/main/java/java/lang/Object.java (revision 378507)
+++ kernel/src/main/java/java/lang/Object.java (working copy)
@@ -44,7 +44,16 @@
* Cloneable.
*/
protected Object clone() throws CloneNotSupportedException {
+ try
+ {
+ Class cls = Class.forName("java.lang.Cloneable");
+ cls.isInstance(this);
+ }
+ catch (Exception e)
+ {
return null;
+ }
+ return VMObject.clone((Cloneable)this);
};
/**
@@ -60,7 +69,7 @@
* @see #hashCode
*/
public boolean equals(Object o) {
- return false;
+ return (o == this);
}
/**
@@ -89,7 +98,7 @@
* @return Class the receiver's Class
*/
public final Class getClass() {
- return null;
+ return VMObject.getClass(this);
};
/**
@@ -101,7 +110,7 @@
* @see #equals
*/
public int hashCode() {
- return 0;
+ return VMSystem.identityHashCode(this);
};
/**
@@ -117,6 +126,7 @@
* @see java.lang.Thread
*/
public final void notify() {
+ VMObject.notify(this);
return;
};
@@ -135,6 +145,7 @@
* @see java.lang.Thread
*/
public final void notifyAll() {
+ VMObject.notifyAll(this);
return;
};
@@ -145,7 +156,10 @@
* @return String a printable representation for the receiver.
*/
public String toString() {
- return null;
+ int hc = VMSystem.identityHashCode(this);
+ Integer ihc = new Integer(hc);
+ String retVal = new String(ihc.toString());
+ return retVal;
}
/**
@@ -171,6 +185,7 @@
* @see java.lang.Thread
*/
public final void wait() throws InterruptedException {
+ VMObject.wait(this, 0, 0);
return;
}
@@ -198,6 +213,7 @@
* @see java.lang.Thread
*/
public final void wait(long time) throws InterruptedException {
+ VMObject.wait(this, time, 0);
return;
}
@@ -227,6 +243,7 @@
* @see java.lang.Thread
*/
public final void wait(long time, int frac) throws InterruptedException {
+ VMObject.wait(this, time, frac);
return;
};
}
Index: kernel/src/main/java/java/lang/String.java
===================================================================
--- kernel/src/main/java/java/lang/String.java (revision 378507)
+++ kernel/src/main/java/java/lang/String.java (working copy)
@@ -902,7 +902,30 @@
*
* @return the interned string equal to this String
*/
- public native String intern();
+ //public native String intern();
+ private String [] internArray = new String[256];
+ public String intern()
+ {
+ //System.out.println("String.intern() has a very crude, simple implemention");
+
+ for (int ii = 0; ii < internArray.length; ii++)
+ {
+ if (this.equals(internArray[ii]))
+ return internArray[ii];
+ if (internArray[ii] == null)
+ {
+ internArray[ii] = this;
+ return this;
+ }
+ }
+ int ii = 0;
+ while (true)
+ {
+ //System.out.println("String.intern() --- error, overflowed intern storage");
+ ii++;
+ }
+ }
+
/**
* Searches in this String for the last index of the specified character.
Index: kernel/src/main/java/java/lang/Thread.java
===================================================================
--- kernel/src/main/java/java/lang/Thread.java (revision 378507)
+++ kernel/src/main/java/java/lang/Thread.java (working copy)
@@ -40,11 +40,19 @@
// a thread
public final static int NORM_PRIORITY = 5; // Normal priority for a thread
- Object slot1;
+ Runnable runnableSlot;
+ //////String threadNameSlot; //maybe same as next one
+ String name;
+ /////ThreadGroup threadGroupSlot; //maybe same as next one
+ ThreadGroup group;
+ ////VMThread threadSlot; //maybe same as next one
+ VMThread vmThread;
+ ///boolean isDaemonSlot; //maybe this is the same as daemon
+ boolean daemon;
+ ThreadLocal threadLocalSlot;
+ long stackSlot;
+ int priority;
- Object slot2;
-
- Object slot3;
/**
* Constructs a new Thread with no runnable object and a newly generated
@@ -53,8 +61,17 @@
*
* @see java.lang.ThreadGroup
*/
+ public Thread(VMThread vmt1, String s1, int i1, boolean b1)
+ {
+ super();
+ vmThread = vmt1;
+ name = s1;
+ priority = i1;
+ daemon = b1;
+ }
public Thread() {
super();
+ vmThread = new VMThread();
}
/**
@@ -70,6 +87,8 @@
*/
public Thread(Runnable runnable) {
super();
+ runnableSlot = runnable;
+ vmThread = new VMThread();
}
/**
@@ -87,6 +106,10 @@
*/
public Thread(Runnable runnable, String threadName) {
super();
+ runnableSlot = runnable;
+ name = threadName;
+ vmThread = new VMThread();
+
}
/**
@@ -101,6 +124,8 @@
*/
public Thread(String threadName) {
super();
+ name = threadName;
+ vmThread = new VMThread();
}
/**
@@ -122,8 +147,11 @@
* @see java.lang.SecurityException
* @see java.lang.SecurityManager
*/
- public Thread(ThreadGroup group, Runnable runnable) {
+ public Thread(ThreadGroup gr, Runnable runnable) {
super();
+ group = gr;
+ runnableSlot = runnable;
+ vmThread = new VMThread();
}
/**
@@ -149,9 +177,13 @@
* @see java.lang.SecurityException
* @see java.lang.SecurityManager
*/
- public Thread(ThreadGroup group, Runnable runnable, String threadName,
+ public Thread(ThreadGroup gr, Runnable runnable, String threadName,
long stack) {
super();
+ group = gr;
+ runnableSlot = runnable;
+ name = threadName;
+ vmThread = new VMThread();
}
/**
@@ -175,8 +207,12 @@
* @see java.lang.SecurityException
* @see java.lang.SecurityManager
*/
- public Thread(ThreadGroup group, Runnable runnable, String threadName) {
+ public Thread(ThreadGroup gr, Runnable runnable, String threadName) {
super();
+ group = gr;
+ runnableSlot = runnable;
+ name = threadName;
+ vmThread = new VMThread();
}
/**
@@ -196,8 +232,11 @@
* @see java.lang.SecurityException
* @see java.lang.SecurityManager
*/
- public Thread(ThreadGroup group, String threadName) {
+ public Thread(ThreadGroup gr, String threadName) {
super();
+ group = gr;
+ name = threadName;
+ vmThread = new VMThread();
}
/**
@@ -206,7 +245,7 @@
* @return Number of Threads
*/
public static int activeCount() {
- return 0;
+ return 1; //wjw fixit --- but still an OK value for initial bringup
}
/**
@@ -220,7 +259,7 @@
* @see java.lang.SecurityManager
*/
public final void checkAccess() {
- return;
+ return; //wjw fixit leave security off for now
}
/**
@@ -232,7 +271,7 @@
* not, and suspend was deprecated too.
*/
public int countStackFrames() {
- return 0;
+ return vmThread.countStackFrames();
}
/**
@@ -243,7 +282,7 @@
* currentThread()
*/
public static Thread currentThread() {
- return null;
+ return VMThread.currentThread();
};
/**
@@ -251,7 +290,7 @@
*
*/
public void destroy() {
- return;
+ return; //wjw fixit -- this seems reasonable for initial bringup
}
/**
@@ -259,7 +298,7 @@
*
*/
public static void dumpStack() {
- return;
+ //VMThrowable.getStackTrace(this); //wjw fixit
}
/**
@@ -278,7 +317,7 @@
* @see java.lang.SecurityManager
*/
public static int enumerate(Thread[] threads) {
- return 0;
+ return 0; //wjw fixit --- I don't see thread group support in JCHEVM native methods
}
/**
@@ -298,7 +337,8 @@
* @return the receiver's name (a java.lang.String)
*/
public final String getName() {
- return null;
+ String ss = name + this.toString();
+ return this.toString(); //wjw fixit
}
/**
@@ -308,7 +348,7 @@
* @see Thread#setPriority
*/
public final int getPriority() {
- return 0;
+ return 0; //wjw fixit
}
/**
@@ -317,7 +357,7 @@
* @return the receiver's ThreadGroup
*/
public final ThreadGroup getThreadGroup() {
- return null;
+ return group; //wjw fixit --- is this correct?
}
/**
@@ -332,7 +372,7 @@
* @see #setThreadLocal
*/
Object getThreadLocal(ThreadLocal local) {
- return null;
+ return threadLocalSlot.get(); //wjw fixit -- is this correct?
}
/**
@@ -347,6 +387,7 @@
* @see Thread#isInterrupted
*/
public void interrupt() {
+ vmThread.interrupt();
return;
}
@@ -362,7 +403,7 @@
* @see Thread#isInterrupted
*/
public static boolean interrupted() {
- return false;
+ return VMThread.interrupted();
};
/**
@@ -375,7 +416,7 @@
* @see Thread#start
*/
public final boolean isAlive() {
- return false;
+ return false; //wjw fixit -- but its probably OK for bringup
}
/**
@@ -389,7 +430,7 @@
* @see Thread#setDaemon
*/
public final boolean isDaemon() {
- return false;
+ return daemon;
}
/**
@@ -402,7 +443,7 @@
* @see Thread#interrupted
*/
public boolean isInterrupted() {
- return false;
+ return vmThread.isInterrupted();
}
/**
@@ -479,7 +520,9 @@
* @see Thread#start
*/
public void run() {
+ if (runnableSlot == null)
return;
+ runnableSlot.run();
}
/**
@@ -506,7 +549,7 @@
* @see Thread#isDaemon
*/
public final void setDaemon(boolean isDaemon) {
- return;
+ daemon = isDaemon;
}
/**
@@ -520,7 +563,7 @@
* @see Thread#getName
*/
public final void setName(String threadName) {
- return;
+ name = threadName;
}
/**
@@ -540,7 +583,8 @@
* @see Thread#getPriority
*/
public final void setPriority(int priority) {
- return;
+ vmThread.nativeSetPriority(priority);
+ return; //wjw fixit -- leave this till later
}
/**
@@ -556,6 +600,7 @@
* @see #getThreadLocal
*/
void setThreadLocal(ThreadLocal local, Object value) {
+ threadLocalSlot.set(value);
return;
}
@@ -604,6 +649,26 @@
* @see Thread#run
*/
public void start() {
+ //wjw -- the s1 and s2 strings are easy to spot in jchevm since string creation calls into the jvm
+ //wjw -- the below is used as a debugging aid
+ String s1 = "Thread.start() -- TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
+ int stackSize = 1024 * 64;
+ vmThread.thread = this;
+ if (java.lang.ThreadGroup.root == null)
+ {
+ java.lang.ThreadGroup tg = new java.lang.ThreadGroup();
+ java.lang.ThreadGroup.root = tg;
+ }
+ group = java.lang.ThreadGroup.root; //wjw temporary, during bringup
+ vmThread.start(stackSize);
+ String s2 = "Thread.start() -- BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
+ int xx = 0;
+ /*
+ while (true)
+ {
+ xx++;
+ }
+ */
return;
}
@@ -664,7 +729,7 @@
* @return a printable representation for the receiver.
*/
public String toString() {
- return null;
+ return name.toString();
}
/**
@@ -674,7 +739,7 @@
*
*/
public static void yield() {
- return;
+ VMThread.yield();
};
/**
@@ -687,7 +752,7 @@
* object
*/
public static boolean holdsLock(Object object) {
- return false;
+ return false; //wjw fixit -- is this supported in JCHEVM????
};
}
Index: kernel/src/main/java/java/lang/Throwable.java
===================================================================
--- kernel/src/main/java/java/lang/Throwable.java (revision 378507)
+++ kernel/src/main/java/java/lang/Throwable.java (working copy)
@@ -40,6 +39,8 @@
public class Throwable implements java.io.Serializable {
private static final long serialVersionUID = -3042686055658047285L;
+ private VMThrowable vmState; //wjw required by jchevm:: _jc_bootstrap_classes
+
/**
* The message provided when the exception was created.
*/
@@ -63,6 +64,7 @@
*/
public Throwable() {
super();
+ //System.out.println("Throwable.UNSET_MARK means the mark has not been set.
*/
Index: nio/src/main/java/com/ibm/platform/OSMemory.java
===================================================================
--- nio/src/main/java/com/ibm/platform/OSMemory.java (revision 378507)
+++ nio/src/main/java/com/ibm/platform/OSMemory.java (working copy)
@@ -42,7 +42,8 @@
* above.
*
false for Big Endian, and
* truevalue into first length bytes of the
@@ -163,7 +182,10 @@
* @param length
* the number of byte-length locations to set.
*/
- public native void memset(long address, byte value, long length);
+ public void memset(long address, byte value, long length)
+ {
+ //wjw
+ }
/**
* Copies length bytes from srcAddress to
@@ -186,7 +208,10 @@
* @param length
* the number of bytes to move.
*/
- public native void memmove(long destAddress, long srcAddress, long length);
+ public void memmove(long destAddress, long srcAddress, long length)
+ {
+ //wjw
+ }
/**
* Copies length bytes from the memory block at
@@ -212,8 +237,11 @@
* @throws IndexOutOfBoundsException
* if offset + length > bytes.length.
*/
- public native void getByteArray(long address, byte[] bytes, int offset,
- int length) throws NullPointerException, IndexOutOfBoundsException;
+ public void getByteArray(long address, byte[] bytes, int offset,
+ int length) throws NullPointerException, IndexOutOfBoundsException
+ {
+ //wjw
+ }
/**
* Copies length bytes from the byte array bytes
@@ -241,8 +269,11 @@
* @throws IndexOutOfBoundsException
* if offset + length > bytes.length.
*/
- public native void setByteArray(long address, byte[] bytes, int offset,
- int length) throws NullPointerException, IndexOutOfBoundsException;
+ public void setByteArray(long address, byte[] bytes, int offset,
+ int length) throws NullPointerException, IndexOutOfBoundsException
+ {
+ //wjw
+ }
// Primitive get & set methods
@@ -257,7 +288,10 @@
* the platform address of the byte.
* @return the byte value.
*/
- public native byte getByte(long address);
+ public byte getByte(long address)
+ {
+ return 0; //wjw
+ }
/**
* Sets the given single byte value at the given address.
@@ -271,7 +305,10 @@
* @param value
* the value to set.
*/
- public native void setByte(long address, byte value);
+ public void setByte(long address, byte value)
+ {
+ //wjw
+ }
/**
* Gets the value of the signed two-byte integer stored in platform byte
@@ -286,7 +323,10 @@
* the platform address of the start of the two-byte value.
* @return the value of the two-byte integer as a Java short.
*/
- public native short getShort(long address);
+ public short getShort(long address)
+ {
+ return 0; //wjw
+ }
public short getShort(long address, Endianness endianness) {
return (endianness == NATIVE_ORDER) ? getShort(address)
@@ -307,7 +347,10 @@
* @param value
* the value of the two-byte integer as a Java short.
*/
- public native void setShort(long address, short value);
+ public void setShort(long address, short value)
+ {
+ //wjw
+ }
public void setShort(long address, short value, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -330,7 +373,10 @@
* the platform address of the start of the four-byte value.
* @return the value of the four-byte integer as a Java int.
*/
- public native int getInt(long address);
+ public int getInt(long address)
+ {
+ return 0; //wjw
+ }
public int getInt(long address, Endianness endianness) {
return (endianness == NATIVE_ORDER) ? getInt(address)
@@ -351,7 +397,10 @@
* @param value
* the value of the four-byte integer as a Java int.
*/
- public native void setInt(long address, int value);
+ public void setInt(long address, int value)
+ {
+ //wjw
+ }
public void setInt(long address, int value, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -374,7 +423,10 @@
* the platform address of the start of the eight-byte value.
* @return the value of the eight-byte integer as a Java long.
*/
- public native long getLong(long address);
+ public long getLong(long address)
+ {
+ return 0L; //wjw
+ }
public long getLong(long address, Endianness endianness) {
return (endianness == NATIVE_ORDER) ? getLong(address)
@@ -396,7 +448,10 @@
* the value of the eight-byte integer as a Java
* long.
*/
- public native void setLong(long address, long value);
+ public void setLong(long address, long value)
+ {
+ //wjw
+ }
public void setLong(long address, long value, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -419,7 +474,10 @@
* the platform address of the start of the eight-byte value.
* @return the value of the four-byte float as a Java float.
*/
- public native float getFloat(long address);
+ public float getFloat(long address)
+ {
+ return (float)0.0; //wjw
+ }
public float getFloat(long address, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -443,7 +501,10 @@
* @param value
* the value of the four-byte float as a Java float.
*/
- public native void setFloat(long address, float value);
+ public void setFloat(long address, float value)
+ {
+ //wjw
+ }
public void setFloat(long address, float value, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -467,7 +528,10 @@
* the platform address of the start of the eight-byte value.
* @return the value of the eight-byte float as a Java double.
*/
- public native double getDouble(long address);
+ public double getDouble(long address)
+ {
+ return 0.0; //wjw
+ }
public double getDouble(long address, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -492,7 +556,10 @@
* the value of the eight-byte float as a Java
* double.
*/
- public native void setDouble(long address, double value);
+ public void setDouble(long address, double value)
+ {
+ //wjw
+ }
public void setDouble(long address, double value, Endianness endianness) {
if (endianness == NATIVE_ORDER) {
@@ -518,7 +585,10 @@
* the platform address of the start of the platform pointer.
* @return the value of the platform pointer as a Java long.
*/
- public native long getAddress(long address);
+ public long getAddress(long address)
+ {
+ return 0L; //wjw
+ }
/**
* Sets the value of the platform pointer at the given address.
@@ -537,13 +607,19 @@
* @param value
* the value of the platform pointer as a Java long.
*/
- public native void setAddress(long address, long value);
+ public void setAddress(long address, long value)
+ {
+ //wjw
+ }
/*
* Memory mapped file
*/
- private native long mmapImpl(long fileDescriptor, long alignment,
- long size, int mapMode);
+ private long mmapImpl(long fileDescriptor, long alignment,
+ long size, int mapMode)
+ {
+ return 0L;
+ }
public PlatformAddress mmap(long fileDescriptor, long alignment, long size,
int mapMode) throws IOException {
@@ -555,7 +631,10 @@
// return PlatformAddress.on(address, true);
}
- private native void unmapImpl(long addr);
+ private void unmapImpl(long addr)
+ {
+ //wjw
+ }
public void unmap(PlatformAddress addr) {
long osAddr = addr.toLong();
@@ -568,19 +647,28 @@
loadImpl(addr.toLong(), size);
}
- private native int loadImpl(long l, long size);
+ private int loadImpl(long l, long size)
+ {
+ return 0; //wjw
+ }
public boolean isLoaded(PlatformAddress addr, long size) {
return size == 0 ? true : isLoadedImpl(addr.toLong(), size);
}
- private native boolean isLoadedImpl(long l, long size);
+ private boolean isLoadedImpl(long l, long size)
+ {
+ return false; //wjw
+ }
public void flush(PlatformAddress addr, long size) {
flushImpl(addr.toLong(), size);
}
- private native int flushImpl(long l, long size);
+ private int flushImpl(long l, long size)
+ {
+ return 0; //wjw
+ }
/*
* Helper methods to change byte order.
Index: nio/src/main/java/com/ibm/platform/OSFileSystem.java
===================================================================
--- nio/src/main/java/com/ibm/platform/OSFileSystem.java (revision 378507)
+++ nio/src/main/java/com/ibm/platform/OSFileSystem.java (working copy)
@@ -51,10 +51,16 @@
}
}
- private native int lockImpl(long fileDescriptor, long start, long length,
- int type, boolean wait);
+ private int lockImpl(long fileDescriptor, long start, long length,
+ int type, boolean wait)
+ {
+ return 0; //wjw
+ }
- public native int getPageSize();
+ public int getPageSize()
+ {
+ return 1024*4; //wjw
+ }
public boolean lock(long fileDescriptor, long start, long length, int type,
boolean waitFlag) throws IOException {
@@ -64,7 +70,10 @@
return result != -1;
}
- private native int unlockImpl(long fileDescriptor, long start, long length);
+ private int unlockImpl(long fileDescriptor, long start, long length)
+ {
+ return 0; //wjw
+ }
public void unlock(long fileDescriptor, long start, long length)
throws IOException {
@@ -76,7 +85,10 @@
}
}
- private native int fflushImpl(long fd, boolean metadata);
+ private int fflushImpl(long fd, boolean metadata)
+ {
+ return 0; //wjw
+ }
public void fflush(long fileDescriptor, boolean metadata)
throws IOException {
@@ -90,7 +102,10 @@
* File position seeking.
*/
- private native long seekImpl(long fd, long offset, int whence);
+ private long seekImpl(long fd, long offset, int whence)
+ {
+ return 0; //wjw
+ }
public long seek(long fileDescriptor, long offset, int whence)
throws IOException {
@@ -104,8 +119,11 @@
/*
* Direct read/write APIs work on addresses.
*/
- private native long readDirectImpl(long fileDescriptor, long address,
- int offset, int length);
+ private long readDirectImpl(long fileDescriptor, long address,
+ int offset, int length)
+ {
+ return 0L; //wjw
+ }
public long readDirect(long fileDescriptor, long address, int offset,
int length) throws IOException {
@@ -116,8 +134,11 @@
return bytesRead;
}
- private native long writeDirectImpl(long fileDescriptor, long address,
- int offset, int length);
+ private long writeDirectImpl(long fileDescriptor, long address,
+ int offset, int length)
+ {
+ return 0; //wjw fixit
+ }
public long writeDirect(long fileDescriptor, long address, int offset,
int length) throws IOException {
@@ -132,8 +153,11 @@
/*
* Indirect read/writes work on byte[]'s
*/
- private native long readImpl(long fileDescriptor, byte[] bytes, int offset,
- int length);
+ private long readImpl(long fileDescriptor, byte[] bytes, int offset,
+ int length)
+ {
+ return 0L; //wjw
+ }
public long read(long fileDescriptor, byte[] bytes, int offset, int length)
throws IOException {
@@ -144,16 +168,45 @@
return bytesRead;
}
- private native long writeImpl(long fileDescriptor, byte[] bytes,
- int offset, int length);
+ private Thread uglyWriteHack;
+
+
+ //private native long writeImpl(long fileDescriptor, byte[] bytes, int offset, int length); //wjw
+ private native void writeImpl(int q1, int q2, int q3, int q4) ; //wjw
+
+ /* ******************88 wjw
+ private long writeImpl(long fileDescriptor, byte[] bytes,
+ int offset, int length)
+ {
+ if (uglyWriteHack == null)
+ {
+ uglyWriteHack = new Thread();
+ }
+ int ii;
+ for (ii=0; ii