Commit Graph

225 Commits

Author SHA1 Message Date
Joel Dice
80c8940b7f ensure joining threads are always notified when a thread exits
Previously, we'd only do this if the thread exited without throwing an
exception.  Now we do it regardless.
2013-02-03 15:18:32 -07:00
Joel Dice
1890e348fb fix handling of classe, method, and field names with non-ASCII characters 2013-02-03 14:10:47 -07:00
Joel Dice
2131adf3aa fix Windows OpenJDK build 2013-01-25 08:07:47 -07:00
Joel Dice
36eee724c9 check argument types in JVM_InvokeMethod
Method.invoke must throw an IllegalArgumentException if it receives
the wrong number or types of arguments, and since this isn't done by
the OpenJDK class library, we must do it in the VM.
2013-01-24 12:16:41 -07:00
Joel Dice
0adccdc99c return unadorned filename from JVM_GetSystemPackage
Package.defineSystemPackage expects a filename, not a URL.
2013-01-24 12:16:40 -07:00
Joel Dice
9f22a701cc load libmawt.so proactively when booting the VM for OpenJDK
This library is placed in the xawt subdirectory of jre/lib/$arch on
POSIX systems, so it isn't found automatically when third-party
libraries which depend on it are loaded.  The simplest way to ensure
that it's found seems to be to just load it when the VM starts up.
2012-12-20 12:30:15 -07:00
Joel Dice
d200019d10 implement JNI reflection methods
These include FromReflectedMethod, ToReflectedMethod,
FromReflectedField, and ToReflectedField.
2012-12-19 12:39:33 -07:00
Joel Dice
1ce012aa68 fix abort in classpath-openjdk.cpp due to buffer overflow
This addresses the case where -Djava.home=<some really long path>.

https://github.com/ReadyTalk/avian/issues/15
2012-10-03 09:43:51 -06:00
Joel Dice
1d4c9d32fb return null from JNIEnv::GetSuperclass for interfaces per spec 2012-09-28 15:03:14 -06:00
Joel Dice
3693201911 make JVM_GetSystemPackage a bit smarter
The original stub implementation just echoed back its argument, but
that confused URLClassLoader when dealing with sealed JARs --
returning a non-null value for a non-system class from
JVM_GetSystemPackage made URLClassloader think it had already loaded a
class from a package which was supposed to be sealed, resulting in
SecurityExceptions which ultimately triggered NoClassDefFoundErrors.
The solution is to only return non-null values for actual system
classes.
2012-09-24 17:43:34 -06:00
Joel Dice
e20c5cd9c6 fix a couple of OpenJDK reflection bugs
We weren't wrapping exceptions thrown by invoked methods in
InvocationTargetExceptions in JVM_InvokeMethod or
JVM_NewInstanceFromConstructor.  Also, JVM_GetCallerClass is supposed
to ignore Method.invoke frames when walking the stack.
2012-09-22 20:22:33 -06:00
Joel Dice
c918cbced1 fix sun.misc.Unsafe.getLongVolatile for static fields on 32-bit platforms
The existing code did not handle static field lookups for
synchronization on 32-bit systems, which is necessary because such
systems generally don't support atomic operations on 64-bit values.
2012-09-11 19:28:02 -06:00
Xerxes Rånby
db0c14d742 Set java.vm.info based on makefile info= and
set java.vm.version based on makefile version=
in order to display relevant OpenJDK -version information.

Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
2012-09-05 15:30:49 +02:00
Joel Dice
3f039864d1 fix memcpy argument order bug in jvmConstantPoolGetDoubleAt 2012-08-29 12:10:31 -06:00
Joel Dice
7534eecdb3 implement JVM_ConstantPoolGetDoubleAt 2012-08-29 18:34:28 -06:00
Joel Dice
374bdb3726 implement Runtime.maxMemory for OpenJDK port
Some apps refuse to run if Runtime.maxMemory returns a value that's
"too small", so our stub implementation returning zero was not
sufficient.  Now we return the actual heap size limit in bytes.
2012-08-29 18:32:45 -06:00
Joel Dice
8c48a44e54 set main thread context classloader correctly for OpenJDK port
sun.misc.Launcher has its own idea about what the application
classloader should be, but we need to override it with the system
classloader created by the VM.  This is achieved by running
Launcher.getLauncher (which has the side effect of setting
Thread.contextClassLoader) and then overriding it.
2012-08-29 18:27:37 -06:00
Joel Dice
47503854d5 Thread.sleep(0) should not sleep indefinitely
Our implementation uses Object.wait(long) to implement Thread.sleep,
which had the side effect of interpreting zero as infinity.  However,
for Thread.sleep, zero just means zero.  I assume that doesn't mean
"don't sleep at all", though, or else the app wouldn't have called
Thread.sleep in the first place, so this patch sleeps for one
millisecond when zero is passed -- just enough to yield the processor
for a bit.  Thread.yield might be a better choice in this case, but I
assume the app would have called that directly if that's what it
wanted.
2012-08-12 11:17:59 -06:00
Joel Dice
01be4b23bb implement JNI methods needed by AWT
These include PushLocalFrame, PopLocalFrame, NewDirectByteBuffer,
GetDirectBufferAddress, and GetDirectBufferCapacity.
2012-08-11 06:56:19 -06:00
Joel Dice
2642a167e2 fix Class.getPackage for system classes in OpenJDK build 2012-08-11 06:46:24 -06:00
Damjan Jovanovic
53b15d1bca look for initIDs in SunFontManager instead of FontManager
OpenJDK 7 has refactored this code relative to OpenJDK 6, and now
FontManager is an interface, with SunFontManager providing a (partial)
implementation.
2012-08-05 19:31:20 -06:00
Damjan Jovanovic
59d7f5a47a fix java.library.path on the ARM platform
On the ARM platform, Avian compiled to use OpenJDK gets this error on
startup:
java/lang/UnsatisfiedLinkError: no zip in java.library.path
  at java/lang/ClassLoader.loadLibrary (line 1860)
  at java/lang/Runtime.loadLibrary0 (line 845)
  at java/lang/System.loadLibrary (line 1084)
  at java/lang/System.initializeSystemClass (line 1145)

Using strace shows why:
[pid 22431]
stat64("/usr/lib/jvm/java-7-openjdk-armhf/jre/lib/i386/libzip.so",
0xbee377e0) = -1 ENOENT (No such file or directory)

The attached patch uses "arm" instead of "i386" in that path. This fixes the
problem.
2012-08-04 07:31:54 -06:00
Damjan Jovanovic
c1aa0b46b5 add support for FreeBSD 2012-08-02 10:41:41 -06:00
Joel Dice
5a5a6a7795 fix C++11 errors and aliasing warning 2012-06-13 19:10:28 -06:00
Joel Dice
7bfb5a6287 fix native method name ambiguity
sun.misc.Unsafe now has two native getByte methods: one which takes a
long and another which takes an Object and a long.  Thus, we need to
decorate each version with its parameter signature so we don't
accidentally call the wrong one at runtime.
2012-06-12 16:33:31 -06:00
Joel Dice
fa8ba2afc8 fix build for recent versions of OpenJDK 7
As of the latest code from the jdk7u-dev Mercurial repository,
java.lang.String no longer has offset or length fields.  Instead, the
content fits exactly into the backing char array, so offset is
implicitly zero and length is the length of the array.  The VM
previously relied on those fields being present, whereas this commit
handles the case where they are not.

In addition, I've made some changes to openjdk-src.mk to ensure that
we can build against both a stock OpenJDK 7 and an IcedTea-patched
version.
2012-06-11 23:30:22 +00:00
Joel Dice
0addd8c814 update copyright years 2012-05-11 17:43:27 -06:00
Joel Dice
e6afc6c321 set Thread.interrupted to true if thread is interrupted outside wait or sleep
This is the correct behavior according to the Thread.interrupt
JavaDoc, and it fixes an intermittent hang on exit in Eclipse.
2012-05-02 11:41:36 -06:00
Joel Dice
deeb3c694c interpret time of zero as infinity when isAbsolute is false in Unsafe.park
This behavior is not covered in the documentation, but
LockSupport.park clearly relies on it.
2012-04-25 17:47:07 -06:00
Joel Dice
1120d8f91d fix ProGuarded openjdk-src build
This makes a simple "hello, world!" app work, at least.  Further
changes may be needed for more sophisticated apps.
2012-04-10 08:18:52 -06:00
Joel Dice
4f0d275e13 run JNI_OnLoad if found in ClassLoader.loadLibrary 2012-03-18 20:10:42 -06:00
Joel Dice
0167868797 various Windows OpenJDK 7 fixes 2012-03-17 18:47:22 -06:00
Joel Dice
8abe9bf469 fix memory leak in freeZipFileEntry 2012-03-17 12:58:41 -06:00
Joel Dice
333b6c59d4 fix non-embedded openjdk build on OS X
The JRE lib dir for OpenJDK 7 on OS X seems to be just "lib", not
e.g. "lib/amd64" by default, so we use that now.  Also, the default
library compatibility version for libjvm.dylib is 0.0.0, but OpenJDK
wants 1.0.0, so we set it explicitly.
2012-03-16 11:01:20 -06:00
Joel Dice
d718bbf833 implement Unsafe.getByte(Object, long) 2012-03-14 12:35:22 -06:00
Joel Dice
eb9f5c6dcc Merge remote branch 'oss/master' into jdk7 2012-03-14 08:22:46 -06:00
Joel Dice
37044236d4 provide dummy implementation of JVM_GetThreadInterruptEvent 2012-03-13 10:31:08 -06:00
Joel Dice
4aefa211a3 File.createNewFile should return false if the file already exists 2012-03-13 08:26:51 -06:00
Joel Dice
3820fec9d7 fix OS X OpenJDK 7 build 2012-03-11 16:26:46 -06:00
Joel Dice
1c2f516b68 Merge remote-tracking branch 'origin/master' into jdk7
Conflicts:
	src/classpath-openjdk.cpp
2012-03-11 15:30:38 -06:00
Joel Dice
6cc0ddda7c implement JVM_HoldsLock 2012-03-11 05:06:08 -06:00
Joel Dice
04a34a75ed implement sun.misc.Unsafe.monitorEnter and monitorExit 2012-03-11 05:05:14 -06:00
Joel Dice
3e38628ad6 check superclasses in fieldForOffset, not just immediate class 2012-03-11 05:04:12 -06:00
Joel Dice
e8e3c9066f implement sun.misc.Unsafe raw memory access methods
The primitive get/put methods are implemented as intrinsics by the
compiler for performance.
2012-03-06 13:07:59 -07:00
Joel Dice
c3b72a3dd5 set sun.boot.class.path property in jvmInitProperties 2012-02-29 11:46:50 -07:00
Joel Dice
747f22115f handle JMM_THREAD_ALLOCATED_MEMORY in JMX GetBoolAttribute implementation 2012-02-21 17:33:51 -07:00
Joel Dice
d94fd952e9 fix some OpenJDK update regressions 2012-02-20 17:38:41 -07:00
Joel Dice
bc5661d6f3 start work on OpenJDK 7 class library port 2012-02-18 15:17:10 -07:00
Joel Dice
c3256c2874 avoid running out of OS resources due to zombie thread accumulation
The bug here is that when a thread exits and becomes a "zombie", the
OS resources associated with it are not necessarily released until we
actually join and dispose of that thread.  Since that only happens
during garbage collection, and collection normally only happens in
response to heap memory pressure, there's no guarantee that we'll GC
frequently enough to clean up zombies promptly and avoid running out
of resources.

The solution is to force a GC whenever we start a new thread and there
are at least N zombies waiting to be disposed, where N=16 for now.
2012-02-03 12:00:02 -07:00
Joel Dice
d29513c653 fix Avian_sun_misc_Unsafe_compareAndSwapLong for platforms without atomicCompareAndSwap64
We never define atomicCompareAndSwap64 for ARM or PowerPC, and
apparently only very recent ARM chips support it, so we must fall back
to synchronization-based emulation.
2012-01-15 10:02:36 -07:00
Joel Dice
49d19456d0 fix infinite wait in Unsafe.park
There were a couple of problems with the Avian_sun_misc_Unsafe_park
implementation in classpath-openjdk.cpp.  First, the wait time should
be interpreted as milliseconds if absolute, but as nanoseconds
otherwise, whereas we were treating it as milliseconds in both cases.
Second, there was no mechanism to exit the while loop after the
specified time; the only way we could exit was via an unpark or
interrupt.
2012-01-14 20:27:40 -07:00
Joel Dice
4b9cb4f4e4 enable JMX support for openjdk-src build and implement GetInputArgumentArray 2011-08-05 18:06:29 -06:00
Joel Dice
e3662f13a9 update copyright years and increment version number 2011-07-13 08:25:21 -06:00
Joel Dice
05f26983d0 implement more sun.misc.Unsafe methods 2011-05-26 17:41:15 -06:00
Joel Dice
2b229b4b6d add stub implementations of JVM_{Enable|Disable}Compiler 2011-05-16 10:33:46 -06:00
Joel Dice
0987255552 tolerate missing classes in interceptFileOperations
If we fail to resolve a given class (e.g. due to ProGuard obfuscating
or eliminating it), just move on to the next one rather than return
immediately.  Otherwise, we may miss intercepting methods of classes
we can resolve.
2011-04-10 17:01:38 -06:00
Joel Dice
7c30e44601 add appropriate memory barriers to double-checked locking code 2011-04-10 14:46:53 -06:00
Joel Dice
3febd7cea7 load libfontmanager.so before trying to resolve FontManager.initIDs
sun.font.FontManager.initIDs is a native method defined in
libfontmanager.so, yet there seems to be no mechanism in OpenJDK's
class library to actually load that library, so we lazily load it
before trying to resolve the method.
2011-04-10 11:26:44 -06:00
Joel Dice
d5fb7f97b9 implement sun.misc.Unsafe.getFloat 2011-04-10 11:26:01 -06:00
Joel Dice
00b829b8e8 fix Class.getDeclaredMethods
Internally, the VM augments the method tables for abstract classes
with any inherited abstract methods to make code simpler elsewhere,
but that means we can't use that table to construct the result of
Class.getDeclaredMethods since it would include methods not actually
declared in the class.  This commit ensures that we preserve and use
the original, un-augmented table for that purpose.
2011-04-09 21:20:56 -06:00
Joel Dice
1476243662 implement sun.misc.Unsafe.putShort 2011-04-09 21:20:21 -06:00
Joel Dice
6707116dd4 implement sun.misc.Unsafe.addressSize 2011-04-09 21:19:49 -06:00
Joel Dice
e1d45cf7c8 add stub implementation of JVM_GetManagement
This is the minimum needed to get Apache Geronimo running.
2011-04-09 21:18:33 -06:00
Joel Dice
b0ae6343ad provide proper implementations of JVM_GetDeclaredClasses, JVM_GetDeclaringClass 2011-03-31 19:47:26 -06:00
Joel Dice
1c7abe782d specify valid code source for system classes
This enables use of a class's protection domain to determine what JAR
or directory it came from.
2011-03-31 19:38:44 -06:00
Joel Dice
384682431a implement JVM_GetSystemPackages stub 2011-03-31 19:00:42 -06:00
Joel Dice
916e6787de set Thread.blocker during thread construction
This avoids an NPE in Thread.blockedOn.
2011-03-31 18:58:59 -06:00
Joel Dice
6506760dd9 implement Unsafe.putByte 2011-03-28 08:55:20 -06:00
Joel Dice
9fe41b2afc only return declared interfaces from Class.getInterfaces
The result of Class.getInterfaces should not include interfaces
declared to be implemented/extended by superclasses/superinterfaces,
only those declared by the class itself.  This is important because it
influences how java.io.ObjectStreamClass calculates serial version
IDs.
2011-03-27 20:29:31 -06:00
Joel Dice
56e832d3e8 fix JVM_GetArrayElement and JVM_SetArrayElement
The old versions only handled object arrays properly, but they need to
handle primitive arrays as well.
2011-03-27 20:25:47 -06:00
Joel Dice
8283e1da46 ignore instances of DelegatingClassLoader in JVM_LatestUserDefinedLoader 2011-03-27 14:13:36 -06:00
Joel Dice
d16bf57634 implement JVM_MaxObjectInspectionAge stub and Unsafe.getShort 2011-03-27 14:12:41 -06:00
Joel Dice
686cbc3637 implement JVM_ResolveClass
This just reuses code in avian.Classes which was formerly only used in
the Avian classpath build.
2011-03-26 23:24:48 -06:00
Joel Dice
ba028b86bf set java.vm.vendor system property during startup 2011-03-26 23:24:05 -06:00
Joel Dice
89947f4655 set default thread context classloader to app loader, not boot loader 2011-03-26 19:01:48 -06:00
Joel Dice
3fd6af152f fix Windows and GCC 3.4 builds 2011-03-26 11:45:33 -06:00
Joel Dice
ba0cc803a6 implement various JVM_* methods
This includes a proper implementation of JVM_ActiveProcessorCount, as
well as JVM_SetLength and JVM_NewMultiArray.  Also, we now accept up
to JNI_VERSION_1_6 in JVM_IsSupportedJNIVersion.
2011-03-26 11:15:52 -06:00
Joel Dice
639ef50079 handle null caller in JVM_GetCallerClass 2011-03-25 19:13:10 -06:00
Joel Dice
7b4b43e119 implement JVM_CompileClass and JVM_CompileClasses stubs
These don't currently do anything but return false.
2011-03-25 19:13:10 -06:00
Joel Dice
7004c0ddf3 various fixes and additions to increase app compatiblity
The main changes here are:

  * fixes for runtime annotation support

  * proper support for runtime generic type introspection

  * throw NoClassDefFoundErrors instead of ClassNotFoundExceptions
    where appropriate
2011-03-17 21:42:15 -06:00
Joel Dice
023e1d93d5 return null for non-array classes in JVM_GetComponentType 2011-03-17 09:41:52 -06:00
Joel Dice
44020482e5 fix GC safety bugs in classpath-openjdk.cpp 2011-03-17 08:43:01 -06:00
Joel Dice
a3a7a7a2de use getcwd instead of getenv("PWD") to get working directory
PWD is not always set, whereas getcwd is more reliable.
2011-03-15 17:33:09 -06:00
Joel Dice
78790a0f68 fix OpenJDK JCE support
This primarily required additions to classpath-openjdk.cpp to
intercept ZipFile, ZipEntry, and JarFile native methods to consult
embedded encryption policy jars when required.
2011-03-04 16:55:31 -07:00
Joel Dice
4db79b9be6 implement various sun.misc.Unsafe and JVM_* methods 2011-03-02 08:35:45 -07:00
Joel Dice
42fd021acf various fixes for running Tomcat on the OpenJDK build 2011-02-25 08:17:15 -07:00
Joel Dice
45674efcea implement JVM_SetSockOpt and Unsafe.getLongVolatile 2011-02-22 18:37:42 -07:00
Joel Dice
bead78d982 wrap primitive return values using correct types in Method.invoke
The VM uses Integer and Long instances internally to wrap the results
of dynamic method invocations, but Method.invoke should use the
correct, specific type for the primitive (e.g. Character for char).
2011-02-22 17:54:56 -07:00
Joel Dice
2ce549d3f8 fix GC safety bug in jvmGetClassInterfaces 2011-02-19 14:07:45 -07:00
Joel Dice
6e19f4dcca use vmRun to execute implementations of JVM_MonitorWait/Notify/NotifyAll
These methods can all throw exceptions, so they must be run using
vmRun to avoid unwinding past the JVM entry points.
2011-02-14 18:55:11 -07:00
Joel Dice
cb7dc1aeef fix various regressions due to 0.5 work 2011-02-11 21:13:11 -07:00
Joel Dice
aa9c887fb4 implement Thread.yield 2011-02-01 18:14:32 -07:00
Joel Dice
afabe8e07e rework VM exception handling; throw OOMEs when appropriate
This rather large commit modifies the VM to use non-local returns to
throw exceptions instead of simply setting Thread::exception and
returning frame-by-frame as it used to.  This has several benefits:

 * Functions no longer need to check Thread::exception after each call
   which might throw an exception (which would be especially tedious
   and error-prone now that any function which allocates objects
   directly or indirectly might throw an OutOfMemoryError)

 * There's no need to audit the code for calls to functions which
   previously did not throw exceptions but later do

 * Performance should be improved slightly due to both the reduced
   need for conditionals and because undwinding now occurs in a single
   jump instead of a series of returns

The main disadvantages are:

 * Slightly higher overhead for entering and leaving the VM via the
   JNI and JDK methods

 * Non-local returns can make the code harder to read

 * We must be careful to register destructors for stack-allocated
   resources with the Thread so they can be called prior to a
   non-local return

The non-local return implementation is similar to setjmp/longjmp,
except it uses continuation-passing style to avoid the need for
cooperation from the C/C++ compiler.  Native C++ exceptions would have
also been an option, but that would introduce a dependence on
libstdc++, which we're trying to avoid for portability reasons.

Finally, this commit ensures that the VM throws an OutOfMemoryError
instead of aborting when it reaches its memory ceiling.  Currently, we
treat the ceiling as a soft limit and temporarily exceed it as
necessary to allow garbage collection and certain internal allocations
to succeed, but refuse to allocate any Java objects until the heap
size drops back below the ceiling.
2010-12-27 15:55:23 -07:00
Joel Dice
651ad20fc3 fix GC safety bugs 2010-12-09 22:17:57 -07:00
Joel Dice
3d49173b0b avoid inifinite recursion if java.lang.Object is missing; refactoring
When trying to create an array class, we try to resolve
java.lang.Object so we can use its vtable in the array class.
However, if Object is missing, we'll try to create and throw a
ClassNotFoundException, which requires creating an array to store the
stack trace, which requires creating an array class, which requires
resolving Object, etc..  This commit short-circuits this process by
telling resolveClass not to create and throw an exception if it can't
find Object.

While doing the above work, I noticed that the implementations of
Classpath::makeThrowable in classpath-avian.cpp and
classpath-openjdk.cpp were identical, so I made makeThrowable a
top-level function.

Finally, I discovered that Thread.setDaemon can only be called before
the target thread has been started, which allowed me to simplify the
code to track daemon threads in the VM.
2010-12-09 19:38:12 -07:00
Joel Dice
d381ece44b rework loadLibrary interception to handle builtins properly 2010-12-08 21:38:16 -07:00
Joel Dice
1271678d41 various fixes for embedded resource loading in OpenJDK build 2010-12-05 17:40:50 -07:00
Joel Dice
4a3b5ad1ab fix windows cross openjdk-src build
This mainly involves some makefile ugliness to work around bugs in the
native Windows OpenJDK code involving conflicting static and
not-static declarations which GCC 4.0 and later justifiably reject but
MSVC tolerates.
2010-12-01 20:05:22 -07:00
Joel Dice
6d1ad1e5ba intercept UnixFileSystem.checkAccess calls to handle embedded java home case 2010-12-01 13:40:43 -07:00
Joel Dice
8f06ac402a compare library to RTLD_DEFAULT, not zero in JVM_FindLibraryEntry
Although RTLD_DEFAULT is zero on Linux, it's not on OS X.
2010-12-01 09:54:29 -07:00
Joel Dice
21a54cdf55 set java.protocol.handler.pkgs on Windows as well as Posix
Also, fix cut-and-paste error where we should have called
fieldAddendum instead of methodAddendum.
2010-11-30 20:25:48 -07:00
Joel Dice
70a36c05b9 fix time==0 case in Unsafe.park and implement JVM_DumpThreads
Also, set name field on system threads for OpenJDK build to avoid NPEs
in Thread.getName.
2010-11-27 16:27:30 -07:00
Joel Dice
e68dfe1e89 various fixes to get Eclipse 3.6 working
* add libnet.so and libnio.so to built-in libraries for openjdk-src build

 * implement sun.misc.Unsafe.park/unpark

 * implement JVM_SetClassSigners/JVM_GetClassSigners

 * etc.
2010-11-27 11:25:02 -07:00
Joel Dice
459f4d5194 fix openjdk-src bootimage build
The main change here is to use a lazily-populated vector to associate
runtime data with classes instead of referencing them directly from
the class which requires updating immutable references in the heap
image.  The other changes employ other strategies to avoid trying to
update immutable references.
2010-11-26 12:41:31 -07:00
Joel Dice
86188cfc04 fix OS X openjdk and openjdk-src builds 2010-11-15 20:28:53 -07:00
Joel Dice
0ca6c3ed53 fix native Windows GCC 3.4 OpenJDK build 2010-11-12 18:29:12 -07:00
Joel Dice
6cf3666ed9 fix timezone lookup for Windows openjdk-src build 2010-11-07 12:24:40 -07:00
Joel Dice
33b945c10b fix Windows openjdk (non-openjdk-src) build 2010-11-07 10:08:04 -07:00
Joel Dice
e1b808024a initial support for Windows OpenJDK build
All the tests are passing for openjdk-src builds, but the non-src
openjdk build is crashing and there's trouble loading time zone info
from the embedded java.home directory.
2010-11-06 22:21:19 -06:00
Joel Dice
df299f3564 fix build against latest JRE 1.6.0_22
This commit accomodates a new field in java.lang.Thread and implements
JVM_FindClassFromBootLoader.
2010-11-05 15:34:28 -06:00
Joel Dice
d0a6096eb0 add support for accessing embedded JARs as if they were directories
This allows OpenJDK to access time zone data which is normally found
under java.home, but which we must embed in the executable itself to
create a self-contained build.  The VM intercepts various file
operations, looking for paths which start with a prefix specified by
the avian.embed.prefix property and redirecting those operations to an
embedded JAR.

For example, if avian.embed.prefix is "/avian-embedded", and code
calls File.exists() with a path of
"/avian-embedded/javahomeJar/foo.txt", the VM looks for a function
named javahomeJar via dlsym, calls the function to find the memory
region containing the embeded JAR, and finally consults the JAR to see
if the file "foo.txt" exists.
2010-11-05 13:18:28 -06:00
Joel Dice
4cb796d2fb only return null from JVM_GetClassLoader when called from Unsafe.getUnsafe
sun.misc.Unsafe.getUnsafe expects a null result if the class loader is
the boot classloader and will throw a SecurityException otherwise
(whereas it should really be checking both for null and comparing
against the system classloader).  However, just returning null
whenever the loader is the boot loader can cause trouble for embedded
apps which put everything in the boot loader, including application
resources.

Therefore, we only return null if it's the boot loader and we're being
called from Unsafe.getUnsafe.
2010-11-04 11:43:50 -06:00
Joel Dice
cabad6926f enable standalone OpenJDK builds
As described in readme.txt, a standalone OpenJDK build embeds all
libraries, classes, and other files needed at runtime in the resulting
binary, eliminating dependencies on external resources.
2010-11-04 11:02:09 -06:00
Joel Dice
6f839323a7 use user-specified boot classpath exclusively when present 2010-10-24 11:49:12 -06:00
Joel Dice
6df0b2cfd9 look for 32-bit JRE libraries under lib/i386 2010-10-23 20:40:48 -06:00
Joel Dice
b023d147df fix JVM_Available for when fd is a fifo or socket 2010-09-23 08:49:36 -06:00
Joel Dice
89f6adc93c fix various classloading deadlocks and races 2010-09-22 13:58:46 -06:00
Joel Dice
efd3ccb04f set java.home to path of JRE, not JDK 2010-09-20 18:38:38 -06:00
Joel Dice
17f495eb27 rework OpenJDK build to derive classpath and library path from environment
We now consult the JAVA_HOME environment variable to determine where
to find the system library JARs and SOs.  Ultimately, we'll want to
support self-contained build, but this allows Avian to behave like a
conventional libjvm.so.
2010-09-20 17:31:23 -06:00
Joel Dice
a0a23b4692 implement JVM_Yield 2010-09-17 16:10:01 -06:00
Joel Dice
d0d53e2e10 fix custom-classloader-related concurrency problems and other bugs
The main changes in this commit ensure that we don't hold the global
class lock when doing class resolution using application-defined
classloaders.  Such classloaders may do their own locking (in fact,
it's almost certain), making deadlock likely when mixed with VM-level
locking in various orders.

Other changes include a fix to avoid overflow when waiting for
extremely long intervals and a GC root stack mapping bug.
2010-09-16 20:49:02 -06:00
Joel Dice
f485016637 implement more JVM_* methods and avoid duplicate array class loading 2010-09-14 18:52:57 -06:00
Joel Dice
d819a75f36 more work towards OpenJDK classpath support
The biggest change in this commit is to split the system classloader
into two: one for boot classes (e.g. java.lang.*) and another for
application classes.  This is necessary to make OpenJDK's security
checks happy.

The rest of the changes include bugfixes and additional JVM method
implementations in classpath-openjdk.cpp.
2010-09-14 10:49:41 -06:00
Joel Dice
66280458c8 implement more JVM_* methods 2010-09-10 17:47:23 -06:00
Joel Dice
cddea7187d preliminary support for using OpenJDK's class library
Whereas the GNU Classpath port used the strategy of patching Classpath
with core classes from Avian so as to minimize changes to the VM, this
port uses the opposite strategy: abstract and isolate
classpath-specific features in the VM similar to how we abstract away
platform-specific features in system.h.  This allows us to use an
unmodified copy of OpenJDK's class library, including its core classes
and augmented by a few VM-specific classes in the "avian" package.
2010-09-10 15:05:29 -06:00