Commit Graph

438 Commits

Author SHA1 Message Date
Joshua Warner
7642b94308 reformat changes since master 2014-07-11 13:25:22 -06:00
Joshua Warner
cbad6931af retypedef object to GcObject*, remove (almost?) all unnecessary reinterpret_casts 2014-07-11 13:25:22 -06:00
Joshua Warner
b0490b8233 finish using setters 2014-07-11 13:25:22 -06:00
Joshua Warner
40e71a4856 use setters in machine.cpp 2014-07-11 13:25:21 -06:00
Joshua Warner
880b9fa910 use setters in machine.h 2014-07-11 13:25:21 -06:00
Joshua Warner
052f2498aa formalize Machine::roots in types.def 2014-07-11 13:25:21 -06:00
Joshua Warner
b4798550a3 add machine.cpp changes 2014-07-11 13:25:20 -06:00
Joshua Warner
4df8f59f3c staticly type finalizer and cleaner 2014-07-11 13:25:20 -06:00
Joshua Warner
b8ddc779a2 staticly type GcReference 2014-07-11 13:25:20 -06:00
Joshua Warner
1da8170c66 apply jnienv + java-common changes 2014-07-11 13:25:19 -06:00
Joshua Warner
9c93c5989c apply classpath-common.h changes 2014-07-11 13:25:19 -06:00
Joshua Warner
00e2307c39 apply machine.h changes 2014-07-11 13:25:19 -06:00
Joshua Warner
9ffbd7e9fe staticly type GcClassLoader instances 2014-07-11 13:25:19 -06:00
Joshua Warner
6a0502bbfe add util.cpp/.h changes 2014-07-11 13:25:19 -06:00
Joshua Warner
51368651dc better statically type Processor interface 2014-07-11 13:25:19 -06:00
Joshua Warner
0ec87c6aa1 statically type Addendum.pool better 2014-07-11 13:25:19 -06:00
Joshua Warner
9f5912c2b6 add stronger typing to method.code 2014-07-11 13:25:19 -06:00
Joshua Warner
9248f8f8ad add stronger typing to code.singleton 2014-07-11 13:25:18 -06:00
Joshua Warner
4754a92b75 split code.stackMap out of code.pool use 2014-07-11 13:25:18 -06:00
Joshua Warner
083dc17810 add stronger typing to code.lineNumberTable 2014-07-11 13:25:18 -06:00
Joshua Warner
194e3b2701 add VMClass changes 2014-07-11 13:25:18 -06:00
Joshua Warner
9b36dca846 generate better typed accessors from type-generator (and switch to using standard library there) 2014-07-11 13:25:17 -06:00
Joshua Warner
263e349cae rename assert to assertT, to avoid conflict with std assert macro 2014-07-11 09:32:57 -06:00
Joshua Warner
b5699cc9dc move Machine::*Type to GcObject::*Type 2014-07-11 09:32:55 -06:00
Joel Dice
1b83ef7eb3 only wrap Exceptions in ExceptionInInitializerErrors, not Errors 2014-07-10 13:43:10 -06:00
Joel Dice
4dc76a50a2 fix case of JNIEnv::FindClass called from JNI_OnLoad
If an JNI_OnLoad implementation calls FindClass when using the OpenJDK
class library, the calling method on the Java stack will be
ClassLoader.loadLibrary.  However, we must use the class loader of the
class attempting to load the library in this case, not the system
classloader.

Therefore, we now maintain a stack such that the latest class to load
a library in the current thread is at the top, and we use that class
whenever FindClass is called by ClassLoader.loadLibrary (via
JNI_OnLoad).

Note that this patch does not attempt to address the same problem for
the Avian or Android class libraries, but the same strategy should
work for them as well.
2014-06-23 17:25:42 -06:00
Joshua Warner
34962ff334 Merge pull request #245 from dicej/jdk8
add support for using the OpenJDK 8 class library
2014-04-24 18:50:38 -06:00
Joel Dice
7de555c797 add support for using the OpenJDK 8 class library
This ensures that all tests pass when Avian is built with an
openjdk=$path option such that $path points to either OpenJDK 7 or 8.

Note that I have not yet tried using the openjdk-src option with
OpenJDK 8.  I'll work on that next.
2014-04-23 15:36:56 -06:00
Joel Dice
9b7d0d1624 update copyright years 2014-04-23 15:33:41 -06:00
Vasily Litvinov
74209edb7d Replacing strcpy with memcpy - should be slightly faster because we're forced to know strlen, so no need in byte-by-byte copying 2014-04-10 01:02:11 +04:00
Vasily Litvinov
5828ef1d46 Fixing property copying 2014-04-09 16:02:48 +04:00
Ilya Mizus
6e3b170393 Trying to solve the properties memory problem 2014-04-09 10:16:53 +04:00
Joel Dice
8740d76154 ensure ClassLoader.getPackage works with all class libraries
There's more work to do to derive all the properties of a given class
from its code source (e.g. JAR file), but this at least ensures that
ClassLoader.getPackage will actually return something non-null when
appropriate.
2014-03-19 11:21:26 -06:00
Joel Dice
866c057f0d fix Class.getDeclaredMethods
getDeclaredMethods was returning methods which were inherited from
interfaces but not (re)declared in the class itself, due to the VM's
internal use of VMClass.methodTable differing from its role in
reflection.  For reflection, we must only include the declared
methods, not the inherited but un-redeclared ones.

Previously, we saved the original method table in
ClassAddendum.methodTable before creating a new one which contains
both declared and inherited methods.  That wasted space, so this patch
replaces ClassAddendum.methodTable with
ClassAddendum.declaredMethodCount, which specifies how many of the
methods in VMClass.methodTable were declared in that class.

Alternatively, we could ensure that undeclared methods always have
their VMMethod.class_ field set to the declaring class instead of the
inheriting class.  I tried this, but it led to subtle crashes in
interface method lookup.  The rest of the VM relies not only on
VMClass.methodTable containing all inherited interface methods but
also that those methods point to the inheriting class, not the
declaring class.  Changing those assumptions would be a much bigger
(and more dangerous in terms of regression potential) effort than I
care to take on right now.  The solution I chose is a bit ugly, but
it's safe.
2014-03-10 08:51:00 -06:00
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