Commit Graph

2333 Commits

Author SHA1 Message Date
Joshua Warner
2800ffe826 rename JNIEXPORT to AVIAN_EXPORT in common.h, to avoid conflicting with jni.h 2013-11-08 08:35:17 -07:00
Joshua Warner
3c1afdd272 make jni.h and avian/machine.h non-interfering 2013-11-07 19:15:31 -07:00
Joshua Warner
d0d4f600dc Merge pull request #94 from dscho/serialization
Implement Java-compatible serialization
2013-11-06 08:49:14 -08:00
Johannes Schindelin
c78923d717 ObjectInputStream: add rudimentary support for objects
This is by no means a complete support for the deserialization compliant
to the Java Language Specification, but it is better to add the support
incrementally, for better readability of the commits.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:10:51 -06:00
Johannes Schindelin
efb3ef9b51 Initialize the context class loader to the app class loader
Previously, we initialized it to the boot class loader, but that is
inconsistent with Java; if compiling against OpenJDK's class library,
the context class loader is therefore initialized to the app class
loader, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:07:58 -06:00
Johannes Schindelin
dba8d39e63 Implement Class#getDeclaredClasses
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:07:58 -06:00
Joshua Warner
790fcff73e Merge pull request #89 from dscho/get-resources
Support ClassLoader#getResources with multiple class path elements
2013-11-04 16:29:40 -08:00
Johannes Schindelin
0602d4a447 Consider all class path elements in SystemClassLoader#findResources
The findResources method is supposed to enumerate all the class path
elements' matching paths' URLs, but we used to stop at the first one.

While this is good enough when the system class path contains only a
single .jar file, since b88438d2(sketch of JAR support in Finder)
supports more than a single .jar file in the class path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:49:31 -06:00
Johannes Schindelin
1864180ea7 Teach Finder to find more than just the first matching element
When the system class path contains more than one .jar, it is quite
concievable that, say, 'META-INF/MANIFEST.MF' can be found in multiple
class path elements.

This commit teaches the working horse of class path inspection, the
Finder class, how to continue the search at a given state.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:44:52 -06:00
Geoff Nixon
69ea1f5721 Bugfixes for Mac OS X, etc. 2013-10-31 01:35:56 -07:00
Johannes Schindelin
0ca8601777 Fix getClass().getComponentType() for higher-dimensional arrays
When creating an object array with more than two dimensions, the
component type was erroneously set to the base type, not the array
type of one less dimension.

This prevented Collection<Class[]>#toArray(Class[][]) from working
properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:31:54 -05:00
Joshua Warner
4285d84406 fix windows.cpp compile for newer versions of mingw 2013-09-11 09:30:35 -06:00
Joel Dice
c06dd28ea0 fix Android classpath build for iOS
This mainly involved reworking the makefile to avoid conflating
Darwin/ARM builds with iOS, since we may also want to build for the
iOS Simulator, which is i386.

Note that I was only able to test this on the Simulator, since I don't
have a real iOS device to test with.  Sorry if I broke something; if
so, please fix it :)
2013-07-31 15:20:32 -07:00
frustaci
a6440375ca Update x86.S
GCC now assumes by default that the stack is aligned to a 16-byte boundary in Linux x86, so let's do our part to honour that. :)
Otherwise native code that depends on the stack to be aligned to 16 bytes would seg fault (like SSE).
https://groups.google.com/forum/#!topic/avian/SyCl-Jfw2U8
2013-07-28 10:39:55 -03:00
Mike Keesey
aab1b6e087 Adding another possible case for addThread to expect. One common case that triggers is is when both arguments to addThread are the same thread (such as the call from attachThread). SWT on darwin seems to do this for dialog boxes. 2013-07-14 15:59:43 -06:00
Joel Dice
82577d742f fix Android classpath build
Hopefully it will stay fixed this time, since we now specify commit
hashes for each dependency which are known to work.
2013-07-05 14:36:16 -06:00
Joel Dice
a9d9bc5d20 fix Clang warnings 2013-07-03 13:33:46 -07:00
Joel Dice
87b02eb949 update copyright years
Previously, I used a shell script to extract modification date ranges
from the Git history, but that was complicated and unreliable, so now
every file just gets the same year range in its copyright header.  If
someone needs to know when a specific file was modified and by whom,
they can look at the Git history themselves; no need to include it
redundantly in the header.
2013-07-02 20:52:38 -06:00
Joel Dice
b3cb20d6eb JVM_GetDeclaredClasses and JVM_GetClassInterfaces should return instances of Class[], not Object[] 2013-06-06 18:37:05 -06:00
Joshua Warner
de21913d13 fix linux->darwin cross-compile
There were two issues: the linux->darwin cross compiler is more stringent
about unused variables, and the makefile specified flags for building ON
darwin that were actually applicable whenever we are building FOR darwin.
2013-06-04 13:32:22 -06:00
Joel Dice
84e23659f9 remove unecessary PROTECT statements
Since there's no possibility of garbage collection during the
lifetimes of these local variables, there's no need to protect the
references.
2013-05-14 14:33:37 -06:00
Simon Ochsenreither
e088fa07ae Make exception messages match the ones from OpenJDK/Android
This commit changes the exception message format of
ClassCastException and CloneNotSupportedException.
2013-05-14 15:04:34 +02:00
Joel Dice
4a69496ab4 perform any necessary argument conversion in JVM_NewInstanceFromConstructor
We must use the same utility function as JVM_InvokeMethod to ensure
that primitive arguments are unboxed when necessary.
2013-05-13 14:27:39 -06:00
Joel Dice
4b0bbd85e8 fix sun.misc.Unsafe.arrayIndexScale implementation
The original implementation was based on the assumption that the
passed class would be the array element type, whereas it is actually
the array type itself.
2013-05-13 14:25:59 -06:00
Joel Dice
6507150246 wait until all non-daemon threads exit before invoking the class library shutdown method
Running the shutdown method prematurely can cause deadlock in
OpenJDK's AWT implementation and may have other nasty effects besides
that.
2013-05-13 13:17:42 -06:00
Joel Dice
fcfdd6be3a initialize the class if necessary when the "new" operator is invoked
This is one of the conditions specified in
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.1,
which I had forgotten about.
2013-05-13 13:12:58 -06:00
Joel Dice
7e2d265fb9 filter flags argument to JVM_Open
The class library may pass non-standard flags to JVM_Open which will
confuse the OS if we pass them through, so we must filter them out.
2013-05-13 13:11:12 -06:00
Joel Dice
6d5fbdeb7b provide stub for JVM_UnloadLibrary
It may leak file handles under certain circumstances to do nothing in
JVM_UnloadLibrary, but, for now, an empty implementation is more
useful than one that aborts the process.
2013-05-13 13:08:40 -06:00
Joel Dice
419ac24963 don't load libmawt ahead of time when starting the VM
At one point, loading libmawt ahead of time was necessary to make AWT
work, but recent versions of OpenJDK seem to take care this from Java
code, in which case loading it ahead of time causes trouble, so we
comment it out for now until we exactly when it's needed.
2013-05-13 13:05:13 -06:00
Joel Dice
435dbbc874 add stub implementation of JVM_CurrentClassLoader 2013-05-10 11:29:20 -06:00
Joel Dice
529c7a17fb add support for the RuntimeVisibleParameterAnnotations attribute 2013-04-30 22:55:59 -06:00
Joel Dice
b1840a297d implement Unsafe.{put|get}Char 2013-04-30 22:54:45 -06:00
Joel Dice
af9e162827 fix OpenJDK build regression due to recent Android classpath refactoring 2013-04-30 22:53:56 -06:00
Joel Dice
bbc5d7fb50 only initialize class when necessary to avoid deadlock
Previously, we would attempt to initialize a class (e.g. call its
static initializer) whenever a method in that class was called, as
well as in any of the cases listed in
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.

However, the above approach may lead to deadlock in an app which
relies on being able to call non-static methods in parallel with a
static initializer invocation in the same class.  Thus, this commit
ensures that we initialize classes only in the cases defined by the
standard.
2013-04-30 22:48:43 -06:00
Joel Dice
ed96693166 do not clear interrupted flag in Unsafe.park
Since park does not throw InterruptedException, we must leave the flag
set if we are interrupted while parked so that
e.g. AbstractQueuedSynchronizer can itself throw an exception if
appropriate.
2013-04-30 22:45:08 -06:00
Joel Dice
4e12847858 code rearrangment to improve state of Android libcore tests
This mainly moves several sun.misc.Unsafe method implementations from
classpath-openjdk.cpp to builtin.cpp so that the Avian and Android
builds can use them.

It also replaces FinalizerReference.finalizeAllEnqueued with a no-op,
since the real implementations assumes too much about how the VM
handles (or delegates) finalization.
2013-04-23 13:47:15 -06:00
Joel Dice
dfdd1f6e6c move call to Classpath::shutDown
We must be in the Active state, not the Exclusive state when calling
this method since it may execute arbitrary Java code.  This fixes an
assertion failure in makeNew.
2013-04-22 21:52:27 -06:00
Joel Dice
8995db69d2 fix element spec calculation for multidimensional primitive arrays
The element class for e.g. [[[I should be [[I, not [I.
2013-04-22 21:28:25 -06:00
Joel Dice
023787d121 fix special case of exception handler table translation
scalac may generate bytecode such that an exception is thrown within
the bounds of a handler for that exception such that the throw is the
last instruction in the method, which we weren't handling properly.
2013-04-22 21:25:15 -06:00
Joel Dice
a18452f6c9 implement JVM_ConstantPoolGetFloatAt
This commit also simplifies JVM_ConstantPoolGetDoubleAt, which cannot
throw an exception and thus need not go through vmRun.
2013-04-22 21:23:32 -06:00
Joel Dice
e3fe9099a2 filter InnerClasses attribute for relevant classes in JVM_GetDeclaredClasses
The InnerClasses attribute may have entries for classes declared
inside classes we don't care about, so we must check each entry's
outer class reference and make sure it matches the one we do care
about.
2013-04-22 21:20:21 -06:00
Joel Dice
63ee3ab0a2 throw CloneNotSupportedException if Object.clone called on non-Cloneable 2013-04-22 21:19:01 -06:00
Joel Dice
e0ceaa5f43 avoid allocating new memory in hashMapRemove when GCing
This ensures that we don't abort when running an internal finalizer
that removes from a hash map.
2013-04-22 21:17:31 -06:00
Joel Dice
68c3b241ce handle sign extension of constants of various lengths
This is a generalization of 9918ea6 which handles 8-bit and 16-bit as
well as 32-bit values.
2013-04-22 21:15:49 -06:00
Joel Dice
d8729a7a8d fix zero-extension of constants in x86 compiler
scalac may emit a ldc followed by an i2c, whereas javac does the
conversion (including zero extension if necessary) at compile time.
This commit ensures we handle the i2c case properly.
2013-04-22 19:00:54 -06:00
Joel Dice
f38c4e25c6 fix array class name length calculation in invoke
The original calculation ommitted the last character, changing
e.g. "[I" into "[".
2013-04-22 18:57:26 -06:00
Joel Dice
e9a8aa2e65 set boot library if run as java or javac command
If sun.java.command or sun.java.launcher are set, then the VM is being
loaded from e.g. libjvm.so, not as a stand-alone executable.  This
commit allows libjvm.dylib to be used with OpenJDK's java command on OS
X.
2013-04-19 18:28:20 -07:00
Joel Dice
a098926547 run Shutdown.shutdown on exit when using OpenJDK library
The OpenJDK library wants to track and run the shutdown hooks itself
rather than let the VM do it, so we need to tell it when we're
exiting.

Also, in machine.cpp we need to use only the modifiers specified in
the InnerClasses attribute for inner classes rather than OR them with
the flags given at the top level of the class file.
2013-04-19 13:00:47 -06:00
Joel Dice
9918ea6cdd fix sign extension from constant to register on x86
scalac may generate a ldc followed by an l2i, whereas javac always
seems to condense this into a single ldc_w.  The former exposed a bug
in the JIT compiler which we never hit with javac-generated bytecode.
2013-04-18 11:27:05 -06:00
Joel Dice
e6b6edfc25 ignore instance variable for static method invocations 2013-04-18 11:25:29 -06:00