View Javadoc

1   // FileSystem.java, created Thu Jul  4  4:50:03 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.Common.java.io;
5   
6   import java.lang.reflect.Method;
7   import joeq.Class.PrimordialClassLoader;
8   import joeq.Class.jq_Class;
9   import joeq.Main.jq;
10  import joeq.Runtime.Reflection;
11  import jwutil.util.Assert;
12  
13  /***
14   * FileSystem
15   *
16   * @author  John Whaley <jwhaley@alum.mit.edu>
17   * @version $Id: FileSystem.java 1941 2004-09-30 03:37:06Z joewhaley $
18   */
19  abstract class FileSystem {
20  
21      public static FileSystem getFileSystem() { return (FileSystem) DEFAULT_FS; }
22      
23      public static final jq_Class _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/FileSystem;");
24      //public static final jq_StaticMethod _getFileSystem = _class.getOrCreateStaticMethod("getFileSystem", "()Ljava/io/FileSystem;");
25      
26      static final Object DEFAULT_FS;
27      static {
28          if (!jq.RunningNative) {
29              Object o;
30              try {
31                  Class klass = Reflection.getJDKType(_class);
32                  Method m = klass.getMethod("getFileSystem", null);
33                  m.setAccessible(true);
34                  o = m.invoke(null, null);
35              } catch (Error x) {
36                  throw x;
37              } catch (Throwable x) {
38                  Assert.UNREACHABLE();
39                  o = null;
40              }
41              DEFAULT_FS = o;
42          } else {
43              Object o = null;
44              Assert.UNREACHABLE();
45              DEFAULT_FS = o;
46          }
47      }
48  }