Commit Graph

404 Commits

Author SHA1 Message Date
Joel Dice
25d69f38ee match Java's schizophrenic concept of inner class access modifiers
An inner class has two sets of modifier flags: one is declared in the
usual place in the class file and the other is part of the
InnerClasses attribute.  Not only is that redundant, but they can
contradict, and the VM can't just pick one and roll with it.  Instead,
Class.getModifiers must return the InnerClasses version, whereas
reflection must check the top-level version.  So even if
Class.getModifiers says the class is protected, it might still be
public for the purpose of reflection depending on what the
InnerClasses attribute says.  Crazy?  Yes.
2014-03-06 16:17:43 -07:00
Joel Dice
bb86500155 fix Method.getModifiers crash due to bootimage miscompile
When calculating field offsets in the bootimage generator, we failed
to consider alignment at inheritence boundaries (i.e. the last field
inherited by from a superclass should be followed by enough padding to
align the first non-inherited field at a machine word boundary).  This
led to a mismatch between native code and Java code in terms of class
layouts, including that of java.lang.reflect.Method.
2014-01-07 09:04:13 -07:00
Joel Dice
7056315c18 fix various Android test suite regressions and add more reflection tests
Most of these regressions were simply due to testing a lot more stuff,
esp. annotations and reflection, revealing holes in the Android
compatibility code.  There are still some holes, but at least the
suite is passing (except for a fragile test in Serialize.java which I
will open an issue for).

Sorry this is such a big commit; there was more to address than I
initially expected.
2013-12-06 18:48:47 -07:00
Joel Dice
abe8bc6fda fix exception wrapping for Method.invoke and static initializers
Method.invoke should initialize its class before invoking the method,
throwing an ExceptionInInitializerError if it fails, without wrapping
said error in an InvocationTargetException.

Also, we must initialize ExceptionInInitializerError.exception when
throwing instances from the VM, since OpenJDK's
ExceptionInInitializerError.getCause uses the exception field, not the
cause field.
2013-12-05 22:28:13 -07:00
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
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
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
529c7a17fb add support for the RuntimeVisibleParameterAnnotations attribute 2013-04-30 22:55:59 -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
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
81d7786716 fix Class.getModifiers for inner classes and implement JVM_GetDeclaringClass and JVM_GetEnclosingMethodInfo properly
This fixes a couple of tests in the Scala test suite
(run/reflection-modulemirror-toplevel-badpath.scala and
run/reflection-constructormirror-nested-good.scala).
2013-04-17 15:12:58 -06:00
Joel Dice
dca75df926 add vmfPrintTrace method for dumping traces to a specific stream 2013-04-09 18:44:34 -06:00
Joel Dice
a648787e11 update method table for all classes in updateClassTables
Previously we only updated this table for non-interfaces, but
interfaces may have methods which need updating too.
2013-03-16 10:54:35 -06:00
Joel Dice
3309a9f4ad ensure that array classes implement Cloneable and Serializable in bootimage build 2013-03-15 13:26:18 -06:00
Joel Dice
3c44cdc50b fix unintentionally retained finalizables and improve low mem performance
Objects which are eligable for finalization must be retained until
after their finalize methods are called.  However, the VM must
determine the entire set of such objects before retaining any of them;
otherwise the process of retaining a given object may cause others to
become reachable and thus be considered ineligible for finalization
even though they are only reachable via other finalizable objects.
The end result of this mistake is that only a few of the objects which
are finalizable will be recognized at each GC cycle, so it requires
many such cycles to find them all, and if new objects become
finalizable at a faster rate, the VM will never catch up and
eventually run out of memory.

This patch fixes the above mistake and also includes tuning to
minimize the need for GC in low memory situations.
2013-03-07 20:32:02 -07:00
Joel Dice
5e2d00010b move headers from src to src/avian
This is necessary to avoid name conflicts on various platforms.  For
example, iOS has its own util.h, and Windows has a process.h.  By
including our version as e.g. "avian/util.h", we avoid confusion with
the system version.
2013-02-27 13:33:29 -07:00
Joel Dice
0a4a04cc09 Merge remote-tracking branch 'github/master' into dicej 2013-02-22 17:13:10 -07:00
Joshua Warner
fc84f62a65 prevent garbage collection as vm shuts down 2013-02-22 16:33:07 -07:00
Joel Dice
9060a31348 Merge remote-tracking branch 'github/master' into dicej
Conflicts:
	src/classpath-openjdk.cpp
2013-02-22 14:43:20 -07:00
Joel Dice
201473cf87 more work on Android classpath port 2013-02-22 11:06:49 -07:00
Joshua Warner
af0e7767eb Merge branch 'master' of github.com:ReadyTalk/avian
Conflicts:
	makefile
2013-02-21 16:23:22 -07:00
Joel Dice
42d39b1af1 more Android class library work 2013-02-21 15:37:17 -07:00
Joshua Warner
48691bb50a move stream.h to include, and type-generator to src/tools 2013-02-20 21:26:34 -07:00
Joel Dice
f04f444f23 modify (THREAD_)RUNTIME_ARRAY definition so RUNTIME_ARRAY_BODY must be used
Previously, if you forgot to use RUNTIME_ARRAY_BODY to reference an
array declared with (THREAD_)RUNTIME_ARRAY, you wouldn't get a
compiler error until you tried to build on e.g. MSVC, where
runtime-sized stack arrays aren't supported.  This change ensures you
find out regardless of what compiler you're using, which ought to
protect us from regressions going forward.
2013-02-20 17:20:17 -07:00
Joshua Warner
52b2fd74ef move math functions out of common.h, and into include/avian/util/math.h 2013-02-20 07:51:57 -07:00
Joshua Warner
b9e281612b move runtime-array to include 2013-02-19 22:56:05 -07:00
Joshua Warner
71765bb26f fix cross-compile windows build 2013-02-15 09:53:02 -07:00
Joshua Warner
34471e5d60 factor out assert / abort / expect implementations 2013-02-13 22:13:52 -07:00
Joshua Warner
3589d5c205 Merge branch 'master' of git://github.com/ReadyTalk/avian
Conflicts:
	src/codegen/arm/assembler.cpp
	src/common.h
	src/machine.cpp
2013-02-12 17:37:19 -07:00
Joshua Warner
964d054117 move RUNTIME_ARRAY into it's own header 2013-02-10 18:07:11 -07:00
Joshua Warner
5dd770d7ea rename cast -> fieldAtOffset 2013-02-10 18:07:03 -07:00
Joshua Warner
2a1834e48a rename mask -> maskAlignedPointer 2013-02-10 18:06:48 -07:00
Joshua Warner
d26d8fdb9f rename ceiling -> ceilingDivide 2013-02-10 18:06:15 -07:00
Joel Dice
5241660463 fix SIGSEGV and off-by-one error in logDebug
We must use separate va_start/va_end pairs for each call to vsnprintf
on Linux and possibly other platforms in order to avoid a crash.
Also, we need to give it room to null terminate the string at the
right point.
2013-02-07 09:33:22 -07:00
Alexey Pelykh
9e4144f92b Trace writeout refactor 2013-02-07 11:39:28 +02:00
Alexey Pelykh
3287b1354a Fix crash if no avian.boostrap is specified (oops) 2013-02-07 11:39:14 +02:00
Alexey Pelykh
ba0ec3759d Fix crash if no avian.boostrap is specified (oops) 2013-02-07 11:39:13 +02:00
Alexey Pelykh
8e879f80a7 Fix crash if no avian.boostrap is specified (oops) 2013-02-07 11:39:12 +02:00
Alexey Pelykh
2e3856211b Fix crash if no avian.boostrap is specified 2013-02-07 11:39:11 +02:00
Alexey Pelykh
e523547b19 Allow avian.bootstrap to accept multiple libraries 2013-02-07 11:39:10 +02:00
Alexey Pelykh
5a1b478b89 Allow output of exceptions to debugger. Generate WinMD file 2013-02-07 11:39:06 +02:00
Joel Dice
5a07e04d56 assert that there are no outstanding Get*Critical requests during allocation
When GetStringCritical or GetPrimitiveArrayCritical are called, the VM
cannot risk new Java heap allocations until the corresponding release
method is called because allocations may result in GC, which cannot
happen while a string or array is pinned in memory.  We already have a
check for this latter in the footprint function used during GC, but
it's best to catch the problem as early as possible.
2013-02-05 09:48:20 -07:00
Joel Dice
e8f8ebdc67 fail quickly if an object allocation cannot be satisfied
Previously, we would blithely exceed the heap ceiling and force the
next allocation to deal with the problem, including a major GC and
possible OutOfMemoryError.  As of this commit, we throw an error
immediately if we find that the allocation will push us over the
ceiling.
2013-02-03 15:53:36 -07:00
Joel Dice
23bb2e8743 force a GC in allocate3 if the heap limit has been exceeded
Otherwise, we'll throw an OOME even though there may be enough
unreachable objects eligible for collection to get back below the
limit.
2013-02-03 15:20:53 -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
3a452309b3 update static table class reference in updateClassTables
Commit c918cbc added this reference to ensure
sun.misc.Unsafe.getLongVolatile could be implemented efficiently on
32-bit platforms.  However, I neglected to ensure the reference was
updated to point to the final class instance instead of the temporary
one used in parseClass.  This led to extra memory usage and
inconsistent locking behavior, plus broken bootimage builds.
2012-10-06 15:25:12 -06:00
Joel Dice
f8d3494b1c clear any weak/soft/phantom references to finalizable objects before queuing
If we don't clear these references, we risk finalizing objects which
can still be reached by one of the special reference types.

It's a bit of a chicken-and-egg problem.  We need to visit finalizable
objects before visiting weak references, since some of the weak
references and/or their targets may become reachable once the
finalizable objects are visited.  However, that ordering means we have
no efficient way of distinguishing between objects which are reachable
from one or more normal GC roots and those which are only reachable
via the finalization queue.  The solution is to clear all weak
references to finalizable objects before visiting them.
2012-10-05 10:06:01 -06:00