Commit Graph

1084 Commits

Author SHA1 Message Date
Joel Dice
fbcdfd6dec Merge remote-tracking branch 'dicej/android-upgrade' 2014-10-08 13:41:50 -06:00
Ilya Mizus
7d4cd23837 Some improvements in the code 2014-10-08 03:46:52 +04:00
Ilya Mizus
d1d97351b9 Reflection improved 2014-10-07 16:50:02 +04:00
Joel Dice
be91d792e4 fix Class.getInterfaces to return only declared interfaces
Previously, we returned all interfaces implemented directly or
indirectly, which did not match the JDK behavior.
2014-10-05 16:28:36 -06:00
Ilya Mizus
270bbc66f9 Added getGenericInterfaces() and fixed SignatureParser to work for everything except TypeVariable-s 2014-10-04 22:17:49 +04:00
Ilya Mizus
67cafb118c Added isAnonymousClass(), isLocalClass(), isMemberClass() functions to Class class 2014-10-02 23:51:25 +04:00
Joel Dice
b406e9c2ed Merge remote-tracking branch 'origin/master' into android-upgrade 2014-09-24 10:59:39 -06:00
Joel Dice
a81879129a add a TODO comment about class comparison 2014-09-03 16:24:15 -06:00
Joel Dice
831c529a98 make Class.getMethod (and getConstructor) more strict about parameter types
This matches the JDK behavior.
2014-08-28 17:00:33 -06:00
Joel Dice
7f4c0b3118 fix SSL stack and Android JAR resource loading 2014-08-22 07:20:19 -06:00
Joel Dice
b96cc3c575 update to more recent version of Android class library
Lots has changed since we forked Android's libcore, so merging the
latest upstream code has required extensive changes to the
Avian/Android port.

One big change is that we now use Avian's versions of
java.lang.Object, java.lang.Class, java.lang.ClassLoader, some
java.lang.reflect.* classes, etc. instead of the Android versions.
The main reason is that the Android versions have become very
Dex/Dalvik-specific, and since Avian is based on Java class files, not
dex archives, that code doesn't make sense here.  This has the side
benefit that we can share more native code with classpath-avian.cpp
and reduce the amount of Java/C++ code duplication.
2014-08-21 13:42:49 -06:00
Joel Dice
8b83de8985 add avian.Machine.tryNative
This function allows you to call native code such that any
SIGSEGV/SIGBUS/SIGFPE/EXC_ACCESS_VIOLATION/etc. raised by that code is
transformed into a Java exception and thrown by tryNative.  Note that
this effectively results in a longjmp out of whatever function raised
the exception, so any C++ destructors or other cleanup code will not
be run.
2014-08-19 14:03:46 -06:00
Joel Dice
5b618982b5 explicitly override UNUSED definition
Recent versions of jni.h such as the one provided by Debian Jessie's
OpenJDK define UNUSED in a way that conflicts with our definition and
usage, so we need to explicitly undefine it before redefining it to
avoid compiler noise.
2014-08-17 15:34:44 -06:00
Joshua Warner
46f7a45f12 add hashCode and equals methods to java/util/Map
Granted, this is weird - but this is what openjdk does.  Therefore,
some code that is compiled for openjdk (say, protobufs) will treat
calls to Map.hashCode as interface calls instead of virtual calls, as
they would have previously been under avian's classpath.

Also note that this error caused avian to abort in findInterfaceMethod
rather than throw an AbstractMethodError or somesuch - but that's a
problem for another day.
2014-08-15 10:44:22 -06:00
Joel Dice
60ea4b2cc2 Merge pull request #317 from joshuawarner32/cmake-vs
Get cmake build working with visual studio 2013
2014-07-31 08:16:48 -06:00
Joshua Warner
d47fcdc349 fix ubuntu precise mingw math.h problems 2014-07-30 14:15:22 -06:00
Vasily Litvinov
c52a9bdf0d Fixing Avian classpath on Windows 2014-07-29 13:51:33 +04:00
Joel Dice
2a43e68c16 fix all the bugs
So there I was, planning to just fix one little bug: Thread.holdsLock
and Thread.yield were missing for the Android class library.  Easy
enough, right?  So, I added a test, got it passing, and figured I'd go
ahead and run ci.sh with all three class libraries.  Big mistake.

Here's the stuff I found:

 * minor inconsistency in README.md about OpenSSL version

 * untested, broken Class.getEnclosingMethod (reported by Josh)

 * JNI test failed for tails=true Android build

 * Runtime.nativeExit missing for Android build

 * obsolete assertion in CallEvent broke tails=true Android build

 * obsolete superclass field offset padding broke bootimage=true Android build

 * runtime annotation parsing broke bootimage=true Android build
   (because we couldn't modify Addendum.annotationTable for classes in
   the heap image)

 * ci.sh tried building with both android=... and openjdk=..., which
   the makefile rightfully balked at

Sorry this is all in a single commit; I didn't expect so many
unrelated issues, and I'm too lazy to break them apart.
2014-07-12 16:57:24 -06:00
Joshua Warner
836cc41320 bulk, global reformat 2014-07-11 13:25:22 -06:00
Joshua Warner
7642b94308 reformat changes since master 2014-07-11 13:25:22 -06:00
Joshua Warner
b0490b8233 finish using setters 2014-07-11 13:25:22 -06:00
Joshua Warner
a1583f1ecc touch up type safety in types.def 2014-07-11 13:25:20 -06:00
Joshua Warner
1e201e54fc staticly type GcContinuation* 2014-07-11 13:25:20 -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
194e3b2701 add VMClass changes 2014-07-11 13:25:18 -06:00
Joshua Warner
5adb558355 add Code to classpath 2014-07-11 09:32:57 -06:00
Joel Dice
5d3c612d0e fix JNIEnv::FindClass calls from JNI_OnLoad for all supported class libraries
This also fixes the some Android build rot and updates the version of
OpenSSL used.
2014-07-01 10:53:26 -06:00
Joel Dice
254e3f938d fix unused declaration/definition warnings from GCC 4.9 2014-06-30 09:54:01 -06:00
Mike Jensen
809b3493e4 More defensive if getCause() changes 2014-05-30 09:46:38 -06:00
Mike Jensen
8c15c14260 Improved Throwable so that if getCause is overriden the printStackTrace will get the cause 2014-05-30 09:27:37 -06:00
Joel Dice
c0adc9a81e don't use GetPrimitiveArrayCritical when throwing SocketExceptions
690ba9c fixed this for throwIOException, but we didn't notice that
throwSocketException had the same problem.
2014-05-23 10:35:44 -06:00
Joel Dice
7a768f2c69 fix log level inheritance
A Logger which has not had a level set explicitly should inherit its
effective level from its parent, not just default to INFO.
2014-05-20 14:26:56 -06:00
Mike Jensen
0b0071dd7f Fix package for LegacyObjectInputStream (ammending commit to try to force a travis build) 2014-05-20 12:58:27 -06:00
Mike Jensen
a7b548f347 Change ByteArrayOutputStream's toString function to match openJDK's expectation 2014-05-14 17:09:15 -06:00
Joel Dice
c35435e450 fix portability problem in Strings test
There was a test in Strings.java that assumed the default character
encoding was UTF-8, which is an invalid assumption on some platforms
(e.g. Windows).  This modifies the test to specify the encoding
explicitly.
2014-05-09 16:38:33 -06:00
Joel Dice
2f7356863b Merge pull request #249 from joshuawarner32/remove-powerpc
remove powerpc support
2014-05-02 07:13:12 -06:00
Joshua Warner
95cffe90b2 Define user.home property on posix 2014-05-01 11:26:27 -06:00
Joshua Warner
41adb74eb1 remove powerpc support 2014-04-29 13:26:40 -06:00
Mike Jensen
0545c07d33 Added SortedMap interface
I also changed TreeMap to implement the "SortedMap" interface, like it should.  Unfortanetly not all the code to implement the interface was there.  Where it was simple I implemented the additional functions, in the case of headMap, tailMap, subMap we are currently just throwing an UnsupportedOperationException.
2014-04-29 09:52:27 -06:00
Joel Dice
172ef9a7e6 Merge pull request #246 from joshuawarner32/master
Stop using *Critical functions in throwIOException
2014-04-24 19:40:10 -06:00
Joshua Warner
1b17ca146b Merge pull request #242 from dicej/copyright
update copyright years
2014-04-24 18:45:18 -06:00
Joshua Warner
690ba9cdc7 Stop using *Critical functions in throwIOException
This was a bug, wherein upon throwing an exception, we would try to
allocate memory for the message - all while holding a critical
reference to the jbyteArray representing the exception string.  This
caused an expect to fail in allocate3.
2014-04-24 15:23:05 -06:00
Joel Dice
a41efb76c5 avoid NPE in URL.set when file is null 2014-04-23 15:51:57 -06:00
Joel Dice
9b7d0d1624 update copyright years 2014-04-23 15:33:41 -06:00
Joel Dice
4c3e0f3421 Merge pull request #238 from pcarrier/PsPN
CP: Properties.stringPropertyNames()
2014-04-20 19:24:10 -06:00
Mike Jensen
1a8d557c72 Merge pull request #237 from pcarrier/sb
CP: StringBuilder.append(char[])
2014-04-20 08:04:47 -06:00
Pierre Carrier
91282a040f CP: StringBuilder.append(char[]) 2014-04-20 04:24:52 -07:00
Pierre Carrier
a36176baca CP: Properties.stringPropertyNames() 2014-04-20 04:24:14 -07:00
Joel Dice
b74f9e32e9 fix NPE in Field.getAnnotations 2014-04-17 13:16:21 -06:00
Mike Jensen
7192b0081d Small change to make these two structures implement RandomAccess (as they should) 2014-04-16 14:33:32 -06:00
Joel Dice
d00debd250 fix Java 6 build
Java 6's javac is not as smart as Java 7's when it comes to calling
overloaded methods from an inner class, so we have to be more
explicit.
2014-04-07 14:05:54 -06:00
Joel Dice
8f4c0e78ce clean up System.getProperties and related methods
The behavior of Avian's versions of these methods was egregiously
non-standard, and there were problems with the Android implementations
as well.
2014-04-04 13:43:59 -06:00
Joshua Warner
573367e7a1 Merge pull request #212 from dicej/net
various refinements to network implementation
2014-04-02 19:41:21 -06:00
Joel Dice
a7e86e6cd4 implement Unsafe.{get|put}*Volatile 2014-03-31 17:31:28 -06:00
Joel Dice
6e7149061c various refinements to network implementation
The main idea is to make DatagramChannel and *SocketChannel behave in
a way that more closely matches the standard, e.g. allow binding
sockets to addresses without necessarily listening on those addresses
and accept null addresses where appropriate.  It also avoids multiple
redundant DNS lookups.

This commit also implements CharBuffer and BindException, and adds the
Readable interface.
2014-03-31 15:22:14 -06:00
Joshua Warner
debaa7b315 Merge pull request #207 from dicej/composable-continuations
Composable continuations
2014-03-24 12:06:27 -06:00
Joshua Warner
0e8d3d91ee fix build on mingw, which somehow doesn't recognize the UNICODE macro correctly 2014-03-24 10:51:44 -06:00
Joel Dice
c2bfba92f0 consolidate duplicate Cell classes 2014-03-24 10:47:37 -06:00
Joel Dice
959172a112 return naturally from function in Continuations.shift rather than via the continuation
Since the function in question is the only one on the call stack above
the reset method, there's no need to invoke the captured continuation
-- we get the same effect by just returning normally, and it's more
efficient that way.
2014-03-24 09:50:09 -06:00
Joel Dice
fd778c2c76 remove redundant interfaces and generalize shift/reset generics
Turns out Function can do the jobs of both CallbackReceiver and
FunctionReceiver, so I've removed the latter two.

Also, shift and reset should work with a combination of types, not
just a single type, so I've expanded their generic signatures.
2014-03-21 07:38:29 -06:00
Joel Dice
ff57447507 fix handling of multiple shifts delimited by a single reset 2014-03-21 07:38:28 -06:00
Joel Dice
aa3fa1aff4 simplify shift/reset API and add test (currently failing) 2014-03-21 07:38:28 -06:00
Joel Dice
91e4d2b4a1 quick sketch of composable continuation implementation
I've been told by knowledgeable people that it is impossible to
implement composable continuations (AKA delimited continuations AKA
shift/reset) in terms of call-with-current-continuation.  Since I
don't yet understand why that is, I figured it would help my
understanding to attempt it and see how it fails.
2014-03-21 07:38:28 -06:00
Joshua Warner
c5012cda72 Merge pull request #205 from dicej/getPackage
ensure ClassLoader.getPackage works with all class libraries
2014-03-19 17:59:44 -06: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
Mike Jensen
b5d388a718 Added an implemention of ArrayDeque, as well as unit tests
I also used this opportunity to reduce code duplication around other queue/deque implementations.
2014-03-18 19:45:00 -06:00
Joel Dice
58079887a9 fix broken Class.getDeclar{ed|ing}Classes implementations
classpath-common.h's getDeclaringClass was trying to look up
non-existing classes, which led to an abort, and I don't even know
what Class.getDeclaredClasses was trying to do, but it was ugly and
wrong.
2014-03-14 11:10:54 -06:00
Joel Dice
c0d178d5f1 implement ConcurrentHashMap and AtomicReferenceArray
This is the simplest possible ConcurrentHashMap I could come up with
that works and is actually concurrent in the way one would expect.
It's pretty unconventional, being based on a persistent red-black
tree, and not particularly memory-efficient or cache-friendly.  I
think this is a good place to start, though, and it should perform
reasonably well for most workloads.  Patches for a more efficient
implementation are welcome!

I also implemented AtomicReferenceArray, since I was using it in my
first, naive attempt to implement ConcurrentHashMap.

I had to do a bit of refactoring, including moving some non-standard
stuff from java.util.Collections to avian.Data so I could make it
available to code outside the java.util package, which is why I had to
modify several unrelated files.
2014-03-12 10:44:24 -06:00
Mike Jensen
68fca60d21 Added interface BlockingDeque, and implementation for ExecutorCompletionService and LinkedBlockingQueue.
I had to implement a blocking queue for ExecutorCompletionService.  LinkedBlockingQueue could be very easily extended right now to implement the java 7 LinkedBlockingDeque.  Right now LinkedBlockingQueue just synchronizes and depends on LinkedList implementation.  But I wrote a very complete unit test suite so we if we want to put a more concurrent design here, we have a complete test suite to verify against.# Please enter the commit message for your changes. Lines starting
2014-03-10 19:06:37 -06:00
Joshua Warner
ed89e0c67d Merge pull request #194 from jentfoo/FutureTask
Added implementation and tests for FutureTask.
2014-03-10 16:51:36 -06:00
Mike Jensen
ccb6083045 Attempting to prevent interrupting threads after future has completed.
We added a 4th state, so we have "Canceling and Canceled".  We are in canceling state if we previously were running, and will not transition to canceled till after the interrupt has been sent.  So at the end if we are not running, or already canceled, we will sleep, waiting for the interrupt to occur so we can be sure we handle it before we let the thread complete.
This also fixes a condition where we returned true on a cancel after a task has already been canceled
2014-03-10 16:14:10 -06:00
Mike Jensen
d56087240d Changes so that we only set the running thread if we actually ARE the running thread 2014-03-10 12:43:22 -06:00
Mike Jensen
83a31314e0 Added implementation and tests for FutureTask.
I also was missing the set operation for AtomicReference, and cleaned a couple things up from LockSupport.
2014-03-10 10:53:49 -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
Joshua Warner
492294bfe6 Merge pull request #189 from jentfoo/interface_improvements
interface improvements and LockSupport implementation
2014-03-07 20:48:40 -07: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
Mike Jensen
d5e3acd7a5 Add parkBlocker variable to Thread.java 2014-03-03 16:45:28 -07:00
Mike Jensen
7dd799476a Interfaces and the foundation for a ReentrantLock implementation 2014-03-03 16:04:56 -07:00
Mike Jensen
b5dd74c3d8 Adds the Deque interface, and allows LinkedList to implement that interface.
This also changes ConcurrentLinkedQueue to implement the Queue interface, and just throw exceptions for operations which are not currently implemented.
2014-03-03 16:02:12 -07:00
Joel Dice
0a89683eff move Unsafe.get{Object|Int}Volatile from classpath-openjdk.cpp to builtin.cpp
This makes them available in all class libraries, not just the OpenJDK
library.  Note that I've also removed the unecessary idle statements,
per ab4adef.
2014-03-03 14:55:49 -07:00
Joshua Warner
e837502d43 Merge pull request #184 from dicej/zip-available
remove redundant decrement in ZipFile.getInputStream inner class
2014-02-26 15:55:48 -07:00
Joel Dice
094af1e794 remove redundant decrement in ZipFile.getInputStream inner class
We were decrementing the "remaining" field twice for each byte read
using the no-arg read method, which resulted in available() returning
a value that was too small.
2014-02-26 14:48:28 -07:00
Joel Dice
0c298eb513 move OpenJDK.getProtectionDomain into Classes.java
This way, apps can access the CodeSource of a class whether they're
using the OpenJDK class library or the Avian one.
2014-02-26 14:09:42 -07:00
Joshua Warner
4a436bad80 Merge pull request #170 from l1m5/master
Change ConcurrentLinkedQueue.poll(boolean remove) to private.
2014-02-11 15:30:13 -07:00
Ben Limmer
d9ce351a24 Change ConcurrentLinkedQueue.poll(boolean remove) to private.
Since it's not available in the Oracle classpath.
Closes #169.
2014-02-11 14:55:29 -07:00
Joshua Warner
02becdb5bf implement Arrays.deepEquals and Objects.deepEquals 2014-01-30 17:12:34 -07:00
Simon Ochsenreither
57d34808c3 Implement java.util.Objects 2014-01-29 02:10:22 +01:00
Joshua Warner
65ca5752da Implement single quotes in MessageFormat 2014-01-28 09:56:25 -07:00
Simon Ochsenreither
4b54b30439 Add StringIndexOutOfBoundsException and use it in String 2014-01-22 21:06:54 +01:00
Joshua Warner
d2cc630736 implement java/util/Observ* 2014-01-20 10:17:22 -07:00
Joel Dice
ce1d59aac7 stop using Gestalt on OS X
This function has been deprecated for a while and is not even part of
the latest SDK, so it's time to say goodbye.
2014-01-16 17:00:52 -07:00
Joel Dice
c3638b7d10 Merge pull request #156 from jentfoo/concurrency_classpath_extension
Adding more java.util.concurrent interfaces that were missed previously.
2014-01-10 07:58:00 -08:00
Mike Jensen
2aa9de3dfb More interfaces that were missed previously. 2014-01-09 09:50:15 -07:00
Joel Dice
d1eb8c5d11 define ENOTCONN if necessary on Windows 2014-01-08 16:08:32 -07:00
Joel Dice
1f6051bcbc Merge pull request #149 from jentfoo/concurrency_classpath_extension
Concurrency classpath extension (part of the atomic package implementation)
2014-01-03 16:06:04 -08:00
Mike Jensen
3fdf29a670 Small simplfication on this if/else statement 2014-01-03 14:23:48 -07:00
Joel Dice
d1bdf2f8ef fix dumb mistake leading to AIOOBEs in Class.getMethod 2014-01-03 13:58:37 -07:00
Mike Jensen
f7d77473a4 Merge branch 'master' of github.com:ReadyTalk/avian into concurrency_classpath_extension 2014-01-03 08:49:40 -07:00
Joel Dice
789c36a459 move Unsafe.putObjectVolatile and putOrderedObject implementations
This makes them available to all class libraries, not just OpenJDK.
2014-01-02 18:00:53 -07:00