From 615390526d6598c4124370fdd77b55894413cd1d Mon Sep 17 00:00:00 2001 From: brian Date: Sun, 23 May 2004 15:55:56 -0700 Subject: [PATCH] jdk 1.1 part 3 darcs-hash:20040523225556-24bed-6c0a6c7b9daad507503792214d81067f79b914fd.gz --- src/org/ibex/nestedvm/UnixRuntime.java | 2 +- src/org/ibex/nestedvm/util/Platform.java | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/org/ibex/nestedvm/UnixRuntime.java b/src/org/ibex/nestedvm/UnixRuntime.java index 24be4e8..a4b1991 100644 --- a/src/org/ibex/nestedvm/UnixRuntime.java +++ b/src/org/ibex/nestedvm/UnixRuntime.java @@ -986,7 +986,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { } } - private static class MP implements Sort.Sortable { + private static class MP implements Sort.Comparable { public MP(String path, FS fs) { this.path = path; this.fs = fs; } public String path; public FS fs; diff --git a/src/org/ibex/nestedvm/util/Platform.java b/src/org/ibex/nestedvm/util/Platform.java index e1f412a..f9dca10 100644 --- a/src/org/ibex/nestedvm/util/Platform.java +++ b/src/org/ibex/nestedvm/util/Platform.java @@ -8,7 +8,30 @@ import java.text.DateFormatSymbols; public abstract class Platform { Platform() { } - private static final Platform p=null; + private static final Platform p; + + static { + float version; + try { + version = Float.parseFloat(System.getProperty("java.specification.version")); + } catch(Exception e) { + System.err.println("WARNING: " + e + " while trying to find jvm version - assuming 1.1"); + version = 1.1f; + } + String platformClass; + if(version >= 1.4f) platformClass = "Jdk14"; + else if(version >= 1.3f) platformClass = "Jdk13"; + else if(version >= 1.2f) platformClass = "Jdk12"; + else if(version >= 1.1f) platformClass = "Jdk11"; + else throw new Error("JVM Specification version: " + version + " is too old. (see org.ibex.util.Platform to add support)"); + + try { + p = (Platform) Class.forName(Platform.class.getName() + "$" + platformClass).newInstance(); + } catch(Exception e) { + e.printStackTrace(); + throw new Error("Error instansiating platform class"); + } + } abstract boolean _atomicCreateFile(File f) throws IOException; public static boolean atomicCreateFile(File f) throws IOException { return p._atomicCreateFile(f); } @@ -28,7 +51,8 @@ public abstract class Platform { static class Jdk11 extends Platform { boolean _atomicCreateFile(File f) throws IOException { - throw new Error("FIXME"); + // FIXME: Just do this non-atomicly + throw new RuntimeException("FIXME"); } void _socketHalfClose(Socket s, boolean output) throws IOException { throw new IOException("half closing sockets not supported"); -- 1.7.10.4