Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 96279 invoked from network); 1 May 2006 23:13:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 May 2006 23:13:11 -0000 Received: (qmail 94658 invoked by uid 500); 1 May 2006 23:13:08 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 94566 invoked by uid 500); 1 May 2006 23:13:08 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 94493 invoked by uid 99); 1 May 2006 23:13:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 May 2006 16:13:07 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 01 May 2006 16:12:59 -0700 Received: (qmail 95845 invoked by uid 65534); 1 May 2006 23:12:38 -0000 Message-ID: <20060501231238.95844.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r398726 [1/6] - in /incubator/harmony/enhanced/classlibadapter: ./ trunk/ trunk/bin/ trunk/modules/ trunk/modules/kernel/ trunk/modules/kernel/src/ trunk/modules/kernel/src/main/ trunk/modules/kernel/src/main/java/ trunk/modules/kernel/src/... Date: Mon, 01 May 2006 23:11:49 -0000 To: harmony-commits@incubator.apache.org From: archie@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: archie Date: Mon May 1 16:11:39 2006 New Revision: 398726 URL: http://svn.apache.org/viewcvs?rev=398726&view=rev Log: Initial import of GNU Classpath adapater from HARMONY-318. This is copied unmodified from the file "gnuclasspathadapter043006.zip", with two small editorial changes: - Set Subversion svn:eol-style property to "native" for DOS/Unix friendliness. - Concatenated newlines onto files that were missing them at the end. Submitted by: Weldon Washburn Bug#: HARMONY-318 Added: incubator/harmony/enhanced/classlibadapter/ incubator/harmony/enhanced/classlibadapter/trunk/ incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo (with props) incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo (with props) incubator/harmony/enhanced/classlibadapter/trunk/bin/ incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat (with props) incubator/harmony/enhanced/classlibadapter/trunk/doit.sh (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Package.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Runtime.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/StackTraceElement.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/System.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Thread.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ThreadGroup.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Throwable.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMClass.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMClassLoader.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMCompiler.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMObject.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMPackage.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMRuntime.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMStackTraceElement.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMString.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMSystem.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMThread.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMThreadGroup.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/VMThrowable.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ref/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ref/Reference.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Constructor.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Field.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/reflect/Method.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/nio/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/nio/DirectByteBufferImpl.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/security/ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/security/AccessControlContext.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/security/AccessController.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/java/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/java/java/io/ incubator/harmony/enhanced/classlibadapter/trunk/modules/luni/src/main/java/java/io/FileDescriptor.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/platform/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/platform/OSFileSystem.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/com/ibm/platform/OSMemory.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/Buffer.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c (with props) incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h (with props) Added: incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo Mon May 1 16:11:39 2006 @@ -0,0 +1,30 @@ + +class Hello extends Thread { + +public static void main(String args[]) +{ + + byte [] ba = new byte[64]; + + ba [0] = 'H'; ba [1] = 'e'; ba [2] = 'l'; ba [3] = 'l'; ba [4] = 'o'; + + ba [5] = ' '; ba [6] = 'W'; ba [7] = 'o'; ba [8] = 'r'; ba [9] = 'l'; ba[10] = 'd'; ba[11] = ' '; + + + Thread tr = new Hello(); + tr.start(); + + while(true) { //////////for(int ss = 0; ss < 20; ss++) { + for (int qq = 0; qq < 12; qq++) { + System.out.write(ba[qq]); + } + System.out.write('\n'); + } + +} +public void run() { + while(true) { + System.out.write('*'); + } +} +} Propchange: incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.multithread_demo ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo Mon May 1 16:11:39 2006 @@ -0,0 +1,60 @@ +import java.io.*; + +class Hello extends Thread { + +public static void main(String args[]) +{ + String ss = System.getProperty("os.encoding"); + System.out.println("os.encoding = " + ss); + ss = System.getProperty("file.encoding"); + System.out.println("file.encoding = " + ss); + ss = System.getProperty("console.encoding"); + System.out.println("console.encoding = " + ss); + ss = System.getProperty("platform.encoding"); + System.out.println("platform.encoding = " + ss); + + for (int gg = 0; gg < 1; gg++) { + //System.out.println("One entire string of characters"); + //System.out.println("this is sunny wather finally"); + //System.out.write('4'); + //System.out.println("red shirt blue pants"); + + + try { + // NOTE: All this simple app does is write to a file, then + // immediately read it back. + + FileOutputStream fos = new FileOutputStream("c:\\temp\\readwrite.junk"); + + for (int ii = 0; ii < 50; ii++) { + fos.write(ii); + } + + FileInputStream fis = new FileInputStream("c:\\temp\\readwrite.junk"); + + for (int zz = 0; zz < 50; zz++) { + int qq = fis.read(); + System.out.println("data = " + qq); + } + File ff = new File("c:\\temp\\String.txt"); + System.out.println(ff); + if (ff.exists()) { + System.out.println("it exists"); + } + else System.out.println("it does not exist"); + + + } catch (Exception e) { System.out.println("some kinda problem..." + e); } + + + } + +} + +//public void run() { +// while(true) { +// System.out.write('*'); +// } +//} + +} Propchange: incubator/harmony/enhanced/classlibadapter/trunk/Hello.java.println_and_File_IO_demo ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat Mon May 1 16:11:39 2006 @@ -0,0 +1,11 @@ +cd bin + +del com_ibm_platform_OSFileSystem.h +javah.exe -bootclasspath . com.ibm.platform.OSFileSystem +copy com_ibm_platform_OSFileSystem.h c:\temp2\Harmony\native-src\linux.IA32\luni_gnuclasspathadapter + +del java_io_File.h +javah.exe -bootclasspath . java.io.File +copy java_io_File.h c:\temp2\Harmony\native-src\linux.IA32\luni_gnuclasspathadapter + +cd .. Propchange: incubator/harmony/enhanced/classlibadapter/trunk/bin/doit.bat ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/doit.sh URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/doit.sh?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/doit.sh (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/doit.sh Mon May 1 16:11:39 2006 @@ -0,0 +1,14 @@ + +### below are various command line configurations, keep for historical reasons +#./jc.exe --classpath=. --bootclasspath=/usr/local/unzipped_glibj:/usr/local/unzipped_jc:. hello +#./jc.exe --classpath=. --bootclasspath=/usr/local/unzipped_harmony_classlib/bin:. --verbose=class --verbose=jni hello +#gdb run ./jc.exe --classpath=. --bootclasspath=/usr/local/unzipped_harmony_classlib/bin:. --verbose=class hello +#gdb --args ./jc.exe --classpath=. --bootclasspath=/usr/local/unzipped_glibj:/usr/local/unzipped_jc:. hello +#gdb --args ./jc.exe --classpath=. --bootclasspath=/usr/local/unzipped_harmony_classlib/bin:/usr/local/unzipped_jc:. --verbose=class hello +#gdb --args ./jc.exe --classpath=. --bootclasspath=/cygdrive/c/temp2/Harmony/bin:/usr/local/unzipped_jc:. --verbose=class hello +#gdb --args ./jc.exe --classpath=. --bootclasspath=/cygdrive/c/temp2/Harmony/bin:/usr/local/unzipped_jc:. Hello + +gdb --args ./jc.exe --classpath=. --bootclasspath=/cygdrive/c/temp2/Harmony/bin:/usr/local/unzipped_jc:. Hello + + + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/doit.sh ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java Mon May 1 16:11:39 2006 @@ -0,0 +1,9 @@ +package gnu.classpath; + +public abstract class Pointer +{ + //during bootup, jchevm specifically loads this class + //this empty stub is all that is required for simple "hello world" + //see jchevm/libjc/bootstrap.c +} + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java Mon May 1 16:11:39 2006 @@ -0,0 +1,9 @@ +package gnu.classpath; + +public class Pointer32 extends Pointer +{ + //during bootup, jchevm specifically loads this class + //this empty stub is all this is required for simple "hello world" + //see jchevm/libjc/bootstrap.c + int data; +} Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer32.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java Mon May 1 16:11:39 2006 @@ -0,0 +1,9 @@ +package gnu.classpath; + +public class Pointer64 extends Pointer +{ + //during bootup, jchevm specifically loads this class + //this empty stub is all that is required for simple "hello world" + //see jchevm/libjc/bootstrap.c + double data; +} Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/Pointer64.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java Mon May 1 16:11:39 2006 @@ -0,0 +1,8 @@ +package gnu.classpath; + +public class VMStackWalker +{ + //during bootup, jchevm specifically loads this class + //this empty stub is all that is required for simple "hello world" + //see jchevm/libjc/bootstrap.c +} Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/gnu/classpath/VMStackWalker.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java Mon May 1 16:11:39 2006 @@ -0,0 +1,772 @@ +/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.lang; + +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.URL; +import java.security.ProtectionDomain; + + +/** + * This class must be implemented by the vm vendor. The documented natives must + * be implemented to support other provided class implementations in this + * package. An instance of class Class is the in-image representation of a Java + * class. There are three basic types of Classes + *
+ *
Classes representing object types (classes or interfaces) + *
+ *
These are Classes which represent the class of a simple instance as + * found in the class hierarchy. The name of one of these Classes is simply the + * fully qualified class name of the class or interface that it represents. Its + * signature is the letter "L", followed by its name, followed by a + * semi-colon (";").
+ *
Classes representing base types
+ *
These Classes represent the standard Java base types. Although it is not + * possible to create new instances of these Classes, they are still useful for + * providing reflection information, and as the component type of array classes. + * There is one of these Classes for each base type, and their signatures are: + *
    + *
  • B representing the byte base type
  • + *
  • S representing the short base type
  • + *
  • I representing the int base type
  • + *
  • J representing the long base type
  • + *
  • F representing the float base type
  • + *
  • D representing the double base type
  • + *
  • C representing the char base type
  • + *
  • Z representing the boolean base type
  • + *
  • V representing void function return values
  • + *
+ * The name of a Class representing a base type is the keyword which is used to + * represent the type in Java source code (i.e. "int" for the int + * base type.
+ *
Classes representing array classes
+ *
These are Classes which represent the classes of Java arrays. There is + * one such Class for all array instances of a given arity (number of + * dimensions) and leaf component type. In this case, the name of the class is + * one or more left square brackets (one per dimension in the array) followed by + * the signature ofP the class representing the leaf component type, which can + * be either an object type or a base type. The signature of a Class + * representing an array type is the same as its name.
+ *
+ * + */ +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 + * definition of java.lang.Class, however Classes representing base types + * can not be found using this method. + * + * @param className + * The name of the non-base type class to find + * @return the named Class + * @throws ClassNotFoundException + * If the class could not be found + * @see java.lang.Class + */ + public static Class forName(String className) throws ClassNotFoundException { + boolean initializeBoolean = true; // a guess that somehow allows "hello world" to work on jchevm + ClassLoader classloader = null; // a guess that somehow allows "hello world" to work on jchevm + return VMClass.forName(className, initializeBoolean, classloader); + } + + /** + * 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 + * definition of java.lang.Class, however Classes representing base types + * can not be found using this method. Security rules will be obeyed. + * + * @param className + * The name of the non-base type class to find + * @param initializeBoolean + * A boolean indicating whether the class should be initialized + * @param classLoader + * The classloader to use to load the class + * @return the named class. + * @throws ClassNotFoundException + * If the class could not be found + * @see java.lang.Class + */ + public static Class forName(String className, boolean initializeBoolean, + ClassLoader classLoader) throws ClassNotFoundException { + initializeBoolean = true; // a guess that somehow allows "hello world" to work on jchevm + ClassLoader classloader = null; // a guess that somehow allows "hello world" to work on jchevm + return VMClass.forName(className, initializeBoolean, classloader); + } + + /** + * Answers an array containing all public class members of the class which + * the receiver represents and its superclasses and interfaces + * + * @return the class' public class members + * @throws SecurityException + * If member access is not allowed + * @see java.lang.Class + */ + public Class[] getClasses() { + + 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; + } + + /** + * Verify the specified Class using the VM byte code verifier. + * + * @throws VerifyError if the Class cannot be verified + */ + void verify() { + // fixit -- cheat for now, assuming only verifiable classes for "hello world" demos + return; + } + + /** + * Answers the classloader which was used to load the class represented by + * the receiver. Answer null if the class was loaded by the system class + * loader + * + * @return the receiver's class loader or nil + * @see java.lang.ClassLoader + */ + public ClassLoader getClassLoader() { + // fixit -- need to add security checks + return VMClass.getClassLoader(this); + } + + /** + * This must be provided by the vm vendor, as it is used by other provided + * class implementations in this package. Outside of this class, it is used + * by SecurityManager.checkMemberAccess(), classLoaderDepth(), + * currentClassLoader() and currentLoadedClass(). Return the ClassLoader for + * this Class without doing any security checks. The bootstrap ClassLoader + * is returned, unlike getClassLoader() which returns null in place of the + * bootstrap ClassLoader. + * + * @return the ClassLoader + * @see ClassLoader#isSystemClassLoader() + */ + ClassLoader getClassLoaderImpl() { + return VMClass.getClassLoader(this); + }; + + /** + * Answers a Class object which represents the receiver's component type if + * the receiver represents an array type. Otherwise answers nil. The + * component type of an array type is the type of the elements of the array. + * + * @return the component type of the receiver. + * @see java.lang.Class + */ + public Class getComponentType() { + return VMClass.getComponentType (this); + }; + + /** + * Answers a public Constructor object which represents the constructor + * described by the arguments. + * + * @param parameterTypes + * the types of the arguments. + * @return the constructor described by the arguments. + * @throws NoSuchMethodException + * if the constructor could not be found. + * @throws SecurityException + * if member access is not allowed + * @see #getConstructors + */ + public Constructor getConstructor(Class parameterTypes[]) + throws NoSuchMethodException, SecurityException { + + boolean publicOnly = true; //fixit -- find out what publicOnly should be set to + 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; + } + + /** + * Answers an array containing Constructor objects describing all + * constructors which are visible from the current execution context. + * + * @return all visible constructors starting from the receiver. + * @throws SecurityException + * if member access is not allowed + * @see #getMethods + */ + public Constructor[] getConstructors() throws SecurityException { + boolean publicOnly = false; // fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredConstructors(this, publicOnly); + } + + /** + * Answers an array containing all class members of the class which the + * receiver represents. Note that some of the fields which are returned may + * not be visible in the current execution context. + * + * @return the class' class members + * @throws SecurityException + * if member access is not allowed + * @see java.lang.Class + */ + public Class[] getDeclaredClasses() throws SecurityException { + boolean publicOnly = false; // fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredClasses(this, publicOnly); + } + + /** + * Answers a Constructor object which represents the constructor described + * by the arguments. + * + * @param parameterTypes + * the types of the arguments. + * @return the constructor described by the arguments. + * @throws NoSuchMethodException + * if the constructor could not be found. + * @throws SecurityException + * if member access is not allowed + * @see #getConstructors + */ + public Constructor getDeclaredConstructor(Class parameterTypes[]) + throws NoSuchMethodException, SecurityException { + boolean publicOnly = true; //fixit -- find out what publicOnly should be set to + 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; + } + + /** + * Answers an array containing Constructor objects describing all + * constructor which are defined by the receiver. Note that some of the + * fields which are returned may not be visible in the current execution + * context. + * + * @return the receiver's constructors. + * @throws SecurityException + * if member access is not allowed + * @see #getMethods + */ + public Constructor[] getDeclaredConstructors() throws SecurityException { + boolean publicOnly = false; // fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredConstructors(this, publicOnly); + } + + /** + * Answers a Field object describing the field in the receiver named by the + * argument. Note that the Constructor may not be visible from the current + * execution context. + * + * @param name + * The name of the field to look for. + * @return the field in the receiver named by the argument. + * @throws NoSuchFieldException + * if the requested field could not be found + * @throws SecurityException + * if member access is not allowed + * @see #getDeclaredFields + */ + public Field getDeclaredField(String name) throws NoSuchFieldException, + SecurityException { + boolean publicOnly = false; //fixit -- find out what public only should be set to + 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; + } + + /** + * Answers an array containing Field objects describing all fields which are + * defined by the receiver. Note that some of the fields which are returned + * may not be visible in the current execution context. + * + * @return the receiver's fields. + * @throws SecurityException + * If member access is not allowed + * @see #getFields + */ + public Field[] getDeclaredFields() throws SecurityException { + boolean publicOnly = false; // fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredFields(this, publicOnly); + } + + /** + * Answers a Method object which represents the method described by the + * arguments. Note that the associated method may not be visible from the + * current execution context. + * + * @param name + * the name of the method + * @param parameterTypes + * the types of the arguments. + * @return the method described by the arguments. + * @throws NoSuchMethodException + * if the method could not be found. + * @throws SecurityException + * If member access is not allowed + * @see #getMethods + */ + public Method getDeclaredMethod(String name, Class parameterTypes[]) + throws NoSuchMethodException, SecurityException { + boolean publicOnly = false; //fixit -- find out what publicOnly should be set to + Method [] methods = VMClass.getDeclaredMethods(this, publicOnly); + for (int ii = 0; ii < methods.length; ii++) + { + //fixit ---- oops, need to match on parameterTypes also + if (methods[ii].toString() == name) return methods[ii]; + } + NoSuchMethodException nsme = new NoSuchMethodException(); + throw nsme; + } + + /** + * Answers an array containing Method objects describing all methods which + * are defined by the receiver. Note that some of the methods which are + * returned may not be visible in the current execution context. + * + * @throws SecurityException + * if member access is not allowed + * @return the receiver's methods. + * @see #getMethods + */ + public Method[] getDeclaredMethods() throws SecurityException { + boolean publicOnly = false; //fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredMethods(this, publicOnly); + } + + /** + * Answers the class which declared the class represented by the receiver. + * This will return null if the receiver is a member of another class. + * + * @return the declaring class of the receiver. + */ + public Class getDeclaringClass() { + return VMClass.getDeclaringClass(this); + } + + /** + * Answers a Field object describing the field in the receiver named by the + * argument which must be visible from the current execution context. + * + * @param name + * The name of the field to look for. + * @return the field in the receiver named by the argument. + * @throws NoSuchFieldException + * If the given field does not exist + * @throws SecurityException + * If access is denied + * @see #getDeclaredFields + */ + public Field getField(String name) throws NoSuchFieldException, + SecurityException { + boolean publicOnly = true; //fixit -- find out what publicOnly should be set to + 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; + } + + /** + * Answers an array containing Field objects describing all fields which are + * visible from the current execution context. + * + * @return all visible fields starting from the receiver. + * @throws SecurityException + * If member access is not allowed + * @see #getDeclaredFields + */ + public Field[] getFields() throws SecurityException { + boolean publicOnly = true; //fixit -- find out what publicOnly should be set to + Field[] fld = VMClass.getDeclaredFields(this, publicOnly); + return fld; + } + + /** + * Answers an array of Class objects which match the interfaces specified in + * the receiver classes implements declaration + * + * @return Class[] the interfaces the receiver claims to implement. + */ + public Class[] getInterfaces() { + return VMClass.getInterfaces(this); + }; + + /** + * Answers a Method object which represents the method described by the + * arguments. + * + * @param name + * String the name of the method + * @param parameterTypes + * Class[] the types of the arguments. + * @return Method the method described by the arguments. + * @throws NoSuchMethodException + * if the method could not be found. + * @throws SecurityException + * if member access is not allowed + * @see #getMethods + */ + public Method getMethod(String name, Class parameterTypes[]) + throws NoSuchMethodException, SecurityException { + boolean publicOnly = false; //fixit -- find out what publicOnly should be set to + Method [] methods = VMClass.getDeclaredMethods(this, publicOnly); + for (int ii = 0; ii < methods.length; ii++) + { + // fixit need to add code that matches 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; + } + + /** + * Answers an array containing Method objects describing all methods which + * are visible from the current execution context. + * + * @return Method[] all visible methods starting from the receiver. + * @throws SecurityException + * if member access is not allowed + * @see #getDeclaredMethods + */ + public Method[] getMethods() throws SecurityException { + boolean publicOnly = false; //fixit -- find out what publicOnly should be set to + return VMClass.getDeclaredMethods(this, publicOnly); + } + + /** + * Answers an integer which which is the receiver's modifiers. Note that the + * constants which describe the bits which are returned are implemented in + * class java.lang.reflect.Modifier which may not be available on the + * target. + * + * @return the receiver's modifiers + */ + public int getModifiers() { + boolean ignoreInnerClassesAttrib = false; + return VMClass.getModifiers(this, ignoreInnerClassesAttrib); + }; + + /** + * Answers the name of the class which the receiver represents. For a + * description of the format which is used, see the class definition of + * java.lang.Class. + * + * @return the receiver's name. + * @see java.lang.Class + */ + public String getName() { + return VMClass.getName(this); + }; + + /** + * Answers the ProtectionDomain of the receiver. + *

+ * Note: In order to conserve space in embedded targets, we allow this + * method to answer null for classes in the system protection domain (i.e. + * for system classes). System classes are always given full permissions + * (i.e. AllPermission). This is not changeable via the + * java.security.Policy. + * + * @return ProtectionDomain the receiver's ProtectionDomain. + * @see java.lang.Class + */ + public ProtectionDomain getProtectionDomain() { + //fixit -- need a java security expert to tell us what this code should be + return null; + } + + /** + * Answers the ProtectionDomain of the receiver. + *

+ * This method is for internal use only. + * + * @return ProtectionDomain the receiver's ProtectionDomain. + * @see java.lang.Class + */ + ProtectionDomain getPDImpl() { + //fixit -- need a java security expert to tell us what this code should be + return null; + }; + + /** + * Answers a read-only stream on the contents of the resource specified by + * resName. The mapping between the resource name and the stream is managed + * by the class' class loader. + * + * @param resName + * the name of the resource. + * @return a stream on the resource. + * @see java.lang.ClassLoader + */ + public URL getResource(String resName) { + // fixit -- need to find an expert on getResource() + // for "hello world", returning null works OK + return null; + } + + /** + * Answers a read-only stream on the contents of the resource specified by + * resName. The mapping between the resource name and the stream is managed + * by the class' class loader. + * + * @param resName + * the name of the resource. + * @return a stream on the resource. + * @see java.lang.ClassLoader + */ + public InputStream getResourceAsStream(String resName) { + // fixit -- need to find an expert on getResource() + // for "hello world", returning null works OK + return null; + } + + /** + * Answers the signers for the class represented by the receiver, or null if + * there are no signers. + * + * @return the signers of the receiver. + * @see #getMethods + */ + public Object[] getSigners() { + // fixit -- might be something related to Java security + return null; + } + + /** + * Answers the Class which represents the receiver's superclass. For Classes + * which represent base types, interfaces, and for java.lang.Object the + * method answers null. + * + * @return the receiver's superclass. + */ + public Class getSuperclass() { + return VMClass.getSuperclass(this); + }; + + /** + * Answers true if the receiver represents an array class. + * + * @return true if the receiver represents an array class + * false if it does not represent an array class + */ + public boolean isArray() { + return VMClass.isArray(this); + }; + + /** + * Answers true if the type represented by the argument can be converted via + * an identity conversion or a widening reference conversion (i.e. if either + * the receiver or the argument represent primitive types, only the identity + * conversion applies). + * + * @return true the argument can be assigned into the + * receiver false the argument cannot be assigned + * into the receiver + * @param cls + * Class the class to test + * @throws NullPointerException + * if the parameter is null + */ + public boolean isAssignableFrom(Class cls) { + return VMClass.isAssignableFrom(this, cls); + }; + + /** + * Answers true if the argument is non-null and can be cast to the type of + * the receiver. This is the runtime version of the instanceof + * operator. + * + * @return true the argument can be cast to the type of the + * receiver false the argument is null or cannot be + * cast to the type of the receiver + * @param object + * Object the object to test + */ + public boolean isInstance(Object object) { + return VMClass.isInstance(this, object); + }; + + /** + * Answers true if the receiver represents an interface. + * + * @return true if the receiver represents an interface + * false if it does not represent an interface + */ + public boolean isInterface() { + return VMClass.isInterface(this); + } + + /** + * Answers true if the receiver represents a base type. + * + * @return true if the receiver represents a base type + * false if it does not represent a base type + */ + public boolean isPrimitive() { + return VMClass.isPrimitive(this); + }; + + /** + * Answers a new instance of the class represented by the receiver, created + * by invoking the default (i.e. zero-argument) constructor. If there is no + * such constructor, or if the creation fails (either because of a lack of + * available memory or because an exception is thrown by the constructor), + * an InstantiationException is thrown. If the default constructor exists, + * but is not accessible from the context where this message is sent, an + * IllegalAccessException is thrown. + * + * @return a new instance of the class represented by the receiver. + * @throws IllegalAccessException + * if the constructor is not visible to the sender. + * @throws InstantiationException + * if the instance could not be created. + */ + public Object newInstance() throws IllegalAccessException, + InstantiationException { + // fixit -- returning null works OK for simple "hello world" + return null; + } + + /** + * Answers a string containing a concise, human-readable description of the + * receiver. + * + * @return a printable representation for the receiver. + */ + public String toString() { + //System.out.println("Class.toString() -- not implemented"); + return this.toString(); /// is this right??????? + } + + /** + * Returns the Package of which this class is a member. A class has a + * Package iff it was loaded from a SecureClassLoader + * + * @return Package the Package of which this class is a member or null + */ + public Package getPackage() { + // fixit -- returning null works OK for simple "hello world" app + return null; + } + + /** + * Returns the assertion status for this class. Assertion is + * enabled/disabled based on classloader default, package or class default + * at runtime + * + * @return the assertion status for this class + */ + public boolean desiredAssertionStatus() { + //fixit -- returning false works OK for simple "hello world" app + return false; + } + + /** + * This must be provided by the vm vendor, as it is used by other provided + * class implementations in this package. This method is used by + * SecurityManager.classDepth(), and getClassContext() which use the + * parameters (-1, false) and SecurityManager.classLoaderDepth(), + * currentClassLoader(), and currentLoadedClass() which use the parameters + * (-1, true). Walk the stack and answer an array containing the maxDepth + * most recent classes on the stack of the calling thread. Starting with the + * caller of the caller of getStackClasses(), return an array of not more + * than maxDepth Classes representing the classes of running methods on the + * stack (including native methods). Frames representing the VM + * implementation of java.lang.reflect are not included in the list. If + * stopAtPrivileged is true, the walk will terminate at any frame running + * one of the following methods:

    + *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;)Ljava/lang/Object;
  • + *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
  • + *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
  • + *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
  • + *
If one of the doPrivileged methods is found, the walk terminate + * and that frame is NOT included in the returned array. Notes: + *
    + *
  • This method operates on the defining classes of methods on stack. + * NOT the classes of receivers.
  • + *
  • The item at index zero in the result array describes the caller of + * the caller of this method.
  • + *
+ * + * @param maxDepth + * maximum depth to walk the stack, -1 for the entire stack + * @param stopAtPrivileged + * stop at priviledged classes + * @return the array of the most recent classes on the stack + */ + static final Class[] getStackClasses(int maxDepth, boolean stopAtPrivileged) { + //fixit -- returning null works OK for simple "hello world" app + return null; + }; + +} + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Class.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java Mon May 1 16:11:39 2006 @@ -0,0 +1,708 @@ + /* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.lang; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.ProtectionDomain; +import java.util.Enumeration; + + + +/** + * This class must be implemented by the vm vendor. The documented methods and + * natives must be implemented to support other provided class implementations + * in this package. ClassLoaders are used to dynamically load, link and install + * classes into a running image. + * + */ +public /*abstract*/ class ClassLoader { + + static ClassLoader systemClassLoader; + + ClassLoader parent; // jchevm/libcj/bootstrap.c requires the presence of this particular field + Object vmdata; // jchevm/libcj/bootstrap.c requires the presence of this particular field + + static final void initializeClassLoaders() { + //fixit -- does gnu classpath need a callback to init the ClassLoaders during boot? + //for now, simply return. Simple "hello world" is OK with this + return; + } + + /** + * Constructs a new instance of this class with the system class loader as + * its parent. + * + * @exception SecurityException + * if a security manager exists and it does not allow the + * creation of new ClassLoaders. + */ + protected ClassLoader() { + super(); + } + + /** + * Constructs a new instance of this class with the given class loader as + * its parent. + * + * @param parentLoader + * ClassLoader the ClassLoader to use as the new class loaders + * parent. + * @exception SecurityException + * if a security manager exists and it does not allow the + * creation of new ClassLoaders. + * @exception NullPointerException + * if the parent is null. + */ + protected ClassLoader(ClassLoader parentLoader) { + // fixit -- need to verify this is correct code + super(); + } + + /** + * Constructs a new class from an array of bytes containing a class + * definition in class file format. + * + * @param classRep + * byte[] a memory image of a class file. + * @param offset + * int the offset into the classRep. + * @param length + * int the length of the class file. + * @deprecated Use defineClass(String, byte[], int, int) + */ + protected final Class defineClass(byte[] classRep, int offset, int length) + throws ClassFormatError { + // fixit -- need to add the correct code + // returning null works OK for simple "hello world" demo + return null; + } + + /** + * Constructs a new class from an array of bytes containing a class + * definition in class file format. + * + * @param className + * java.lang.String the name of the new class + * @param classRep + * byte[] a memory image of a class file + * @param offset + * int the offset into the classRep + * @param length + * int the length of the class file + */ + protected final Class defineClass(String className, byte[] classRep, + int offset, int length) throws ClassFormatError { + ProtectionDomain pd = null; //fixit -- need a java security expert to look at this. + // setting pd to null is OK for simple "hello world" app + return VMClassLoader.defineClass(this, className, classRep, offset, length, pd); + } + + /** + * Constructs a new class from an array of bytes containing a class + * definition in class file format and assigns the new class to the + * specified protection domain. + * + * @param className + * java.lang.String the name of the new class. + * @param classRep + * byte[] a memory image of a class file. + * @param offset + * int the offset into the classRep. + * @param length + * int the length of the class file. + * @param protectionDomain + * ProtectionDomain the protection domain this class should + * belongs to. + */ + protected final Class defineClass(String className, byte[] classRep, + int offset, int length, ProtectionDomain protectionDomain) + throws java.lang.ClassFormatError { + return VMClassLoader.defineClass(this, className, classRep, offset, length, protectionDomain); + } + + /** + * Overridden by subclasses, by default throws ClassNotFoundException. This + * method is called by loadClass() after the parent ClassLoader has failed + * to find a loaded class of the same name. + * + * @return java.lang.Class the class or null. + * @param className + * String the name of the class to search for. + * @exception ClassNotFoundException + * always, unless overridden. + */ + protected Class findClass(String className) throws ClassNotFoundException { + // fixit -- returning null allows "hello world" to work but is incorrect + return null; + } + + /** + * Attempts to find and return a class which has already been loaded by the + * virtual machine. Note that the class may not have been linked and the + * caller should call resolveClass() on the result if necessary. + * + * @return java.lang.Class the class or null. + * @param className + * String the name of the class to search for. + */ + protected final Class findLoadedClass(String className) { + //System.out.println("ClassLoader.findLoadedClass(String) -- is not implemented"); + return VMClassLoader.findLoadedClass(this, className); + }; + + /** + * Attempts to load a class using the system class loader. Note that the + * class has already been been linked. + * + * @return java.lang.Class the class which was loaded. + * @param className + * String the name of the class to search for. + * @exception ClassNotFoundException + * if the class can not be found. + */ + protected final Class findSystemClass(String className) + throws ClassNotFoundException { + // fixit -- confirm that only the system class loader is being used + return VMClassLoader.findLoadedClass(this, className); + } + + /** + * Returns the specified ClassLoader's parent. + * + * @return java.lang.ClassLoader the class or null. + * @exception SecurityException + * if a security manager exists and it does not allow the + * parent loader to be retrieved. + */ + public final ClassLoader getParent() { + //fixit ---- probably need a security expert to help out here + return null; + } + + /** + * Answers an URL which can be used to access the resource described by + * resName, using the class loader's resource lookup algorithm. The default + * behavior is just to return null. + * + * @return URL the location of the resource. + * @param resName + * String the name of the resource to find. + * @see Class#getResource + */ + public URL getResource(String resName) { + //fixit -- the above says default behavior is to just return null + // is returning null good enough for all cases? + return null; + } + + /** + * Answers an Enumeration of URL which can be used to access the resources + * described by resName, using the class loader's resource lookup algorithm. + * The default behavior is just to return an empty Enumeration. + * + * @return Enumeration the locations of the resources. + * @param resName + * String the name of the resource to find. + */ + public final Enumeration getResources(String resName) throws IOException { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Answers a stream on a resource found by looking up resName using the + * class loader's resource lookup algorithm. The default behavior is just to + * return null. + * + * @return InputStream a stream on the resource or null. + * @param resName + * String the name of the resource to find. + * @see Class#getResourceAsStream + */ + public InputStream getResourceAsStream(String resName) { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Returns the system class loader. This is the parent for new ClassLoader + * instances, and is typically the class loader used to start the + * application. If a security manager is present, and the caller's class + * loader is not null and the caller's class loader is not the same as or an + * ancestor of the system class loader, then this method calls the security + * manager's checkPermission method with a + * RuntimePermission("getClassLoader") permission to ensure it's ok to + * access the system class loader. If not, a SecurityException will be + * thrown. + * + * @return java.lang.ClassLoader the system classLoader. + * @exception SecurityException + * if a security manager exists and it does not allow access + * to the system class loader. + */ + public static ClassLoader getSystemClassLoader() { + try + { + if (systemClassLoader == null) + { + systemClassLoader = new ClassLoader(); + } + } + catch (Exception e) { return null;} + return systemClassLoader; + } + + /** + * Answers an URL specifing a resource which can be found by looking up + * resName using the system class loader's resource lookup algorithm. + * + * @return URL a URL specifying a system resource or null. + * @param resName + * String the name of the resource to find. + * @see Class#getResource + */ + public static URL getSystemResource(String resName) { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Answers an Emuneration of URL containing all resources which can be found + * by looking up resName using the system class loader's resource lookup + * algorithm. + * + * @return Enumeration an Enumeration of URL containing the system resources + * @param resName + * String the name of the resource to find. + */ + public static Enumeration getSystemResources(String resName) + throws IOException { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Answers a stream on a resource found by looking up resName using the + * system class loader's resource lookup algorithm. Basically, the contents + * of the java.class.path are searched in order, looking for a path which + * matches the specified resource. + * + * @return a stream on the resource or null. + * @param resName + * the name of the resource to find. + * @see Class#getResourceAsStream + */ + public static InputStream getSystemResourceAsStream(String resName) { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Invoked by the Virtual Machine when resolving class references. + * Equivalent to loadClass(className, false); + * + * @return java.lang.Class the Class object. + * @param className + * String the name of the class to search for. + * @exception ClassNotFoundException + * If the class could not be found. + */ + public Class loadClass(String className) throws ClassNotFoundException { + //fixit -- resolveIt should probably be set to true + // but for "hello world", it was accidentally set to false + boolean resolveIt = true; + return VMClassLoader.loadClass(className, resolveIt); + } + + /** + * Loads the class with the specified name, optionally linking the class + * after load. Steps are: 1) Call findLoadedClass(className) to determine if + * class is loaded 2) Call loadClass(className, resolveClass) on the parent + * loader. 3) Call findClass(className) to find the class + * + * @return java.lang.Class the Class object. + * @param className + * String the name of the class to search for. + * @param resolveClass + * boolean indicates if class should be resolved after loading. + * @exception ClassNotFoundException + * If the class could not be found. + */ + protected Class loadClass(String className, boolean resolveClass) + throws ClassNotFoundException { + return VMClassLoader.loadClass(className, resolveClass); + } + + /** + * Forces a class to be linked (initialized). If the class has already been + * linked this operation has no effect. + * + * @param clazz + * Class the Class to link. + * @exception NullPointerException + * if clazz is null. + * @see Class#getResource + */ + protected final void resolveClass(Class clazz) { + VMClassLoader.resolveClass(clazz); + } + + /** + * This method must be provided by the vm vendor, as it is used by other + * provided class implementations in this package. A sample implementation + * of this method is provided by the reference implementation. This method + * is used by SecurityManager.classLoaderDepth(), currentClassLoader() and + * currentLoadedClass(). Answers true if the receiver is a system class + * loader. + *

+ * Note that this method has package visibility only. It is defined here to + * avoid the security manager check in getSystemClassLoader, which would be + * required to implement this method anywhere else. + * + * @return boolean true if the receiver is a system class loader + * @see Class#getClassLoaderImpl() + */ + final boolean isSystemClassLoader() { + //fixit -- this gets security out of the way for simple "hello world" + return true; + } + + /** + * Answers true if the receiver is ancestor of another class loader. + *

+ * Note that this method has package visibility only. It is defined here to + * avoid the security manager check in getParent, which would be required to + * implement this method anywhere else. + * + * @param child + * ClassLoader, a child candidate + * @return boolean true if the receiver is ancestor of the parameter + */ + final boolean isAncestorOf(ClassLoader child) { + //fixit -- this gets security out of the way for simple "hello world" + return false; + } + + /** + * Answers an URL which can be used to access the resource + * described by resName, using the class loader's resource lookup + * algorithm. The default behavior is just to return null. + * This should be implemented by a ClassLoader. + * + * @return URL + * the location of the resource. + * @param resName String + * the name of the resource to find. + */ + protected URL findResource(String resName) { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Answers an Enumeration of URL which can be used to access the resources + * described by resName, using the class loader's resource lookup + * algorithm. The default behavior is just to return an empty Enumeration. + * + * @param resName String + * the name of the resource to find. + + * @return Enumeration + * the locations of the resources. + * + * @throws IOException when an error occurs + */ + protected Enumeration findResources(String resName) throws IOException { + //fixit -- apparently Resources are not needed for simple "hello world" + //maybe find someone who knows resources to figure this one out? + return null; + } + + /** + * Answers the absolute path of the file containing the library associated + * with the given name, or null. If null is answered, the system searches + * the directories specified by the system property "java.library.path". + * + * @return String the library file name or null. + * @param libName + * String the name of the library to find. + */ + protected String findLibrary(String libName) { + //fixit -- returning null allows simple "hello world" to work + return null; + } + + /** + * Attempt to locate the requested package. If no package information can be + * located, null is returned. + * + * @param name + * The name of the package to find + * @return The package requested, or null + */ + protected Package getPackage(String name) { + //fixit -- returning null allows simple "hello world" to work + return null; + } + + /** + * Return all the packages known to this class loader. + * + * @return All the packages known to this classloader + */ + protected Package[] getPackages() { + //fixit -- returning null allows simple "hello world" to work + return null; + } + + /** + * Define a new Package using the specified information. + * + * @param name + * The name of the package + * @param specTitle + * The title of the specification for the Package + * @param specVersion + * The version of the specification for the Package + * @param specVendor + * The vendor of the specification for the Package + * @param implTitle + * The implementation title of the Package + * @param implVersion + * The implementation version of the Package + * @param implVendor + * The specification vendor of the Package + * @return The Package created + * @exception IllegalArgumentException + * if the Package already exists + */ + protected Package definePackage(String name, String specTitle, + String specVersion, String specVendor, String implTitle, + String implVersion, String implVendor, URL sealBase) + throws IllegalArgumentException { + //fixit -- returning null allows simple "hello world" to work + return null; + } + + /** + * Gets the signers of a class. + * + * @param c + * The Class object + * @return signers The signers for the class + */ + final Object[] getSigners(Class c) { + //fixit --- perhaps signers is related to security (security is turned off for "hello world" demo) + return null; + } + + /** + * Sets the signers of a class. + * + * @param c + * The Class object + * @param signers + * The signers for the class + */ + protected final void setSigners(Class c, Object[] signers) { + //fixit -- doing a "nop" allows "hello world" to work + return; + } + + /** + * This must be provided by the vm vendor. It is used by + * SecurityManager.checkMemberAccess() with depth = 3. Note that + * checkMemberAccess() assumes the following stack when called. + * <- want this class
+ * Class.getDeclared*();
+ * Class.checkMemberAccess();
+ * SecurityManager.checkMemberAccess(); <- current frame
+ *
Returns the ClassLoader of the method (including natives) at the + * specified depth on the stack of the calling thread. Frames representing + * the VM implementation of java.lang.reflect are not included in the list. + * Notes: + *

    + *
  • This method operates on the defining classes of methods on stack. + * NOT the classes of receivers.
  • + *
  • The item at depth zero is the caller of this method
  • + *
+ * + * @param depth + * the stack depth of the requested ClassLoader + * @return the ClassLoader at the specified depth + */ + static final ClassLoader getStackClassLoader(int depth) { + //fixit -- returning null allows simple "hello world" to work + return null; + }; + + /** + * This method must be included, as it is used by System.load(), + * System.loadLibrary(). The reference implementation of this method uses + * the getStackClassLoader() method. Returns the ClassLoader of the method + * that called the caller. i.e. A.x() calls B.y() calls callerClassLoader(), + * A's ClassLoader will be returned. Returns null for the bootstrap + * ClassLoader. + * + * @return a ClassLoader or null for the bootstrap ClassLoader + */ + static ClassLoader callerClassLoader() { + //fixit -- returning null allows simple "hello world" to work + return null; + } + + /** + * This method must be provided by the vm vendor, as it is called by + * java.lang.System.loadLibrary(). System.loadLibrary() cannot call + * Runtime.loadLibrary() because this method loads the library using the + * ClassLoader of the calling method. Loads and links the library specified + * by the argument. + * + * @param libName + * the name of the library to load + * @param loader + * the classloader in which to load the library + * @exception UnsatisfiedLinkError + * if the library could not be loaded + * @exception SecurityException + * if the library was not allowed to be loaded + */ + static void loadLibraryWithClassLoader(String libName, ClassLoader loader) { + try + { + VMClassLoader.loadClass(libName, true); + } + catch (Exception e) { return;} + return; + } + + /** + * This method must be provided by the vm vendor, as it is called by + * java.lang.System.load(). System.load() cannot call Runtime.load() because + * the library is loaded using the ClassLoader of the calling method. Loads + * and links the library specified by the argument. No security check is + * done. + * + * @param libName + * the name of the library to load + * @param loader + * the classloader in which to load the library + * @param libraryPath + * the library path to search, or null + * @exception UnsatisfiedLinkError + * if the library could not be loaded + */ + static void loadLibraryWithPath(String libName, ClassLoader loader, + String libraryPath) { + //fixit -- returning null allows simple "hello world" to work + return; + } + + /** + * Sets the assertion status of a class. + * + * @param cname + * Class name + * @param enable + * Enable or disable assertion + */ + public void setClassAssertionStatus(String cname, boolean enable) { + //fixit -- doing a "nop" allows "hello world" to work + return; + } + + /** + * Sets the assertion status of a package. + * + * @param pname + * Package name + * @param enable + * Enable or disable assertion + */ + public void setPackageAssertionStatus(String pname, boolean enable) { + //fixit -- doing a "nop" allows simple "hello world" to run + return; + } + + /** + * Sets the default assertion status of a classloader + * + * @param enable + * Enable or disable assertion + */ + public void setDefaultAssertionStatus(boolean enable) { + //fixit -- doing a "nop" allows simple "hello world" to run + return; + } + + /** + * Clears the default, package and class assertion status of a classloader + * + */ + public void clearAssertionStatus() { + //fixit -- doing a "nop" allows simple "hello world" to run + return; + } + + /** + * Answers the assertion status of the named class Returns the assertion + * status of the class or nested class if it has been set. Otherwise returns + * the assertion status of its package or superpackage if that has been set. + * Otherwise returns the default assertion status. Returns 1 for enabled and + * 0 for disabled. + * + * @return int the assertion status. + * @param cname + * String the name of class. + */ + boolean getClassAssertionStatus(String cname) { + //fixit -- returning "false" allows simple "hello world" to run + return false; + } + + /** + * Answers the assertion status of the named package Returns the assertion + * status of the named package or superpackage if that has been set. + * Otherwise returns the default assertion status. Returns 1 for enabled and + * 0 for disabled. + * + * @return int the assertion status. + * @param pname + * String the name of package. + */ + boolean getPackageAssertionStatus(String pname) { + //fixit -- returning "false" allows simple "hello world" to run + return false; + } + + /** + * Answers the default assertion status + * + * @return boolean the default assertion status. + */ + boolean getDefaultAssertionStatus() { + //fixit -- returning "false" allows simple "hello world" to run + return false; + } +} + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/ClassLoader.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java Mon May 1 16:11:39 2006 @@ -0,0 +1,88 @@ +/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.lang; + + +/** + * This class must be implemented by the vm vendor. This class is a placeholder + * for environments which explicitely manage the action of a "Just In Time" + * compiler. + * + * @see Cloneable + */ +public final class Compiler { + + /** + * Low level interface to the JIT compiler. Can return any object, or null + * if no JIT compiler is available. + * + * @return Object result of executing command + * @param cmd + * Object a command for the JIT compiler + */ + public static Object command(Object cmd) { + //fixit -- returning null works for simple "hello world" but need to find out what JIT compiler people think + return null; + } + + /** + * Compiles the class using the JIT compiler. Answers true if the + * compilation was successful, or false if it failed or there was no JIT + * compiler available. + * + * @return boolean indicating compilation success + * @param classToCompile + * java.lang.Class the class to JIT compile + */ + public static boolean compileClass(Class classToCompile) { + //fixit -- returning "false" allows simple "hello world" to work + return false; + } + + /** + * Compiles all classes whose name matches the argument using the JIT + * compiler. Answers true if the compilation was successful, or false if it + * failed or there was no JIT compiler available. + * + * @return boolean indicating compilation success + * @param nameRoot + * String the string to match against class names + */ + public static boolean compileClasses(String nameRoot) { + //fixit -- returning "false" allows simple "hello world" to work + return false; + } + + /** + * Disable the JIT compiler + * + */ + public static void disable() { + //fixit -- doing a "nop" allows simple "hello world" to work + return; + }; + + /** + * Disable the JIT compiler + * + */ + public static void enable() { + //fixit -- doing a "nop" allows simple "hello world" to work + return; + }; + +} + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Compiler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java?rev=398726&view=auto ============================================================================== --- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java (added) +++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java Mon May 1 16:11:39 2006 @@ -0,0 +1,250 @@ +/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.lang; + +/** + * This class must be implemented by the vm vendor. Object is the root of the + * java class hierarchy. All non-base types respond to the messages defined in + * this class. + * + */ + +public class Object { + + /** + * Constructs a new instance of this class. + * + */ + public Object() { + } + + /** + * Answers a new instance of the same class as the receiver, whose slots + * have been filled in with the values in the slots of the receiver. + *

+ * Classes which wish to support cloning must specify that they implement + * the Cloneable interface, since the implementation checks for this. + * + * @return Object a shallow copy of this object. + * @exception CloneNotSupportedException + * if the receiver's class does not implement the interface + * 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); + }; + + /** + * Compares the argument to the receiver, and answers true if they represent + * the same object using a class specific comparison. The + * implementation in Object answers true only if the argument is the exact + * same object as the receiver (==). + * + * @param o + * Object the object to compare with this object. + * @return boolean true if the object is the same as this + * object false if it is different from this object. + * @see #hashCode + */ + public boolean equals(Object o) { + return (o == this); + } + + /** + * Called by the virtual machine when there are no longer any (non-weak) + * references to the receiver. Subclasses can use this facility to guarantee + * that any associated resources are cleaned up before the receiver is + * garbage collected. Uncaught exceptions which are thrown during the + * running of the method cause it to terminate immediately, but are + * otherwise ignored. + *

+ * Note: The virtual machine assumes that the implementation in class Object + * is empty. + * + * @exception Throwable + * The virtual machine ignores any exceptions which are + * thrown during finalization. + */ + + protected void finalize() throws Throwable { + } + + /** + * Answers the unique instance of java.lang.Class which represents the class + * of the receiver. + * + * @return Class the receiver's Class + */ + public final Class getClass() { + return VMObject.getClass(this); + }; + + /** + * Answers an integer hash code for the receiver. Any two objects which + * answer true when passed to .equals must + * answer the same value for this method. + * + * @return int the receiver's hash. + * @see #equals + */ + public int hashCode() { + return VMSystem.identityHashCode(this); + }; + + /** + * Causes one thread which is wait ing on the receiver to be + * made ready to run. This does not guarantee that the thread will + * immediately run. The method can only be invoked by a thread which owns + * the receiver's monitor. + * + * @see #notifyAll + * @see #wait() + * @see #wait(long) + * @see #wait(long,int) + * @see java.lang.Thread + */ + public final void notify() { + VMObject.notify(this); + return; + }; + + /** + * Causes all threads which are wait ing on the receiver to + * be made ready to run. The threads are scheduled according to their + * priorities as specified in class Thread. Between any two threads of the + * same priority the one which waited first will be the first thread that + * runs after being notified. The method can only be invoked by a thread + * which owns the receiver's monitor. + * + * @see #notify + * @see #wait() + * @see #wait(long) + * @see #wait(long,int) + * @see java.lang.Thread + */ + public final void notifyAll() { + VMObject.notifyAll(this); + return; + }; + + /** + * Answers a string containing a concise, human-readable description of the + * receiver. + * + * @return String a printable representation for the receiver. + */ + public String toString() { + int hc = VMSystem.identityHashCode(this); + Integer ihc = new Integer(hc); + String retVal = new String(ihc.toString()); + return retVal; + } + + /** + * Causes the thread which sent this message to be made not ready to run + * pending some change in the receiver (as indicated by notify + * or notifyAll). The method can only be invoked by a thread + * which owns the receiver's monitor. A waiting thread can be sent + * interrupt() to cause it to prematurely stop waiting, so + * senders of wait should check that the condition they were waiting for has + * been met. + *

+ * When the thread waits, it gives up ownership of the receiver's monitor. + * When it is notified (or interrupted) it re-acquires the monitor before it + * starts running. + * + * @exception InterruptedException + * to interrupt the wait. + * @see Thread#interrupt + * @see #notify + * @see #notifyAll + * @see #wait(long) + * @see #wait(long,int) + * @see java.lang.Thread + */ + public final void wait() throws InterruptedException { + VMObject.wait(this, 0, 0); + return; + } + + /** + * Causes the thread which sent this message to be made not ready to run + * either pending some change in the receiver (as indicated by + * notify or notifyAll) or the expiration of + * the timeout. The method can only be invoked by a thread which owns the + * receiver's monitor. A waiting thread can be sent interrupt() + * to cause it to prematurely stop waiting, so senders of wait should check + * that the condition they were waiting for has been met. + *

+ * When the thread waits, it gives up ownership of the receiver's monitor. + * When it is notified (or interrupted) it re-acquires the monitor before it + * starts running. + * + * @param time + * long The maximum time to wait in milliseconds. + * @exception InterruptedException + * to interrupt the wait. + * @see #notify + * @see #notifyAll + * @see #wait() + * @see #wait(long,int) + * @see java.lang.Thread + */ + public final void wait(long time) throws InterruptedException { + VMObject.wait(this, time, 0); + return; + } + + /** + * Causes the thread which sent this message to be made not ready to run + * either pending some change in the receiver (as indicated by + * notify or notifyAll) or the expiration of + * the timeout. The method can only be invoked by a thread which owns the + * receiver's monitor. A waiting thread can be sent interrupt() + * to cause it to prematurely stop waiting, so senders of wait should check + * that the condition they were waiting for has been met. + *

+ * When the thread waits, it gives up ownership of the receiver's monitor. + * When it is notified (or interrupted) it re-acquires the monitor before it + * starts running. + * + * @param time + * long The maximum time to wait in milliseconds. + * @param frac + * int The fraction of a mSec to wait, specified in nano seconds. + * @exception InterruptedException + * to interrupt the wait. + * @see #notify + * @see #notifyAll + * @see #wait() + * @see #wait(long) + * @see java.lang.Thread + */ + public final void wait(long time, int frac) throws InterruptedException { + VMObject.wait(this, time, frac); + return; + }; +} + Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/Object.java ------------------------------------------------------------------------------ svn:eol-style = native