Commit Graph

487 Commits

Author SHA1 Message Date
Jasper Siepkes
c918f2c2e0 Added basic support for the Runtime.maxFree() method. Some applications (BouncyCastle
for example) expect to be able to call this method.
2016-12-16 10:44:11 +01:00
Joel Dice
ca6acb9921 fix a few memory safety issues
The main issue was that offsets for GC roots on the stack were being
miscalculated because invokedynamic bootstrap methods are invoked as
static methods but were not being flagged as such.

Also, I forgot to initialize MyThread::dynamicTable in the constructor
(and why the hell doesn't `gcc -Wall` warn me about stuff like that?)
2016-12-07 10:28:35 -07:00
Joel Dice
69426b9945 fix some lambda bugs
For lambdas that implement java.io.Serializable, the compiler emits
calls to LambdaMetaFactory.altMetafactory, not
LambdaMetaFactory.metafactory, so I've provided a stub implementation
that ignores that currently ignores the extra parameters it receives.

This also fixes a bug in compiling lambda glue code for lambdas that
take longs and/or doubles.
2016-12-04 21:06:07 -07:00
Joel Dice
48dc30dd5a disable Trace.java test when running on Travis-CI
Trace.java fails randomly on Travis, but we've never been able to
reproduce or debug the failure elsewhere, so now we skip it if we
detect the suite is running on Travis.
2016-09-16 14:15:15 -06:00
Joel Dice
81f4d8e92c update ZipOutputStreamTest to use write(byte[]) function as well as others 2016-09-03 14:24:22 -06:00
Joel Dice
a538f54033 add sun.misc.Unsafe.putDouble(Object,long,double) 2016-03-01 18:28:04 -07:00
Joel Dice
3247093b10 disable -Werror by default (but still use it for continuous integration)
Since we can't predict what warnings future compilers will emit, and
most people just want to build Avian without some new warning tripping
it up, we now omit -Werror unless requested via the "use-werror=true"
option to make.  Note that we pass "use-werror=true" in test/ci.sh to
ensure Travis alerts us to new warnings as they appear.

BTW, sorry about the unrelated whitespace changes in this patch; I've
got Emacs set up to fix whitespace "problems" on save, and those are
what it found.
2016-02-15 15:48:30 -07:00
Joel Dice
b5308c4866 synchronize on Java class rather than VM class in static synchronized methods
Previously, the following code would throw an IllegalMonitorStateException:

public class Test {
  public static synchronized void main(String[] args) {
    Test.class.notify();
  }
}

The problem stems from the fact that for a long time Avian has had two
representations of a given class: avian.VMClass and java.lang.Class.
It used to be that there was only one, java.lang.Class, but that
didn't play nicely with OpenJDK's class library, so we split it into
two.  Unfortunately, we forgot to update the JIT and interpreter
accordingly, so a static synchronized method would acquire the
avian.VMClass instance, whereas Foo.class.notify() would be invoked on
the java.lang.Class instance.

This commit fixes it.
2016-01-16 08:34:30 -07:00
Luke Wahlmeier
62a03898c3 Merge remote-tracking branch 'rt/master' 2016-01-10 12:10:47 -07:00
Luke Wahlmeier
9d87e3b2a7 added get/put float/double to ByteBuffers, as well as duplicate 2016-01-10 03:03:03 -07:00
keinhaar
524f034bac Added support for HTTP URL connections, and fixed SocketInputStream and BufferedInputStream.
Did some cleanup as proposed by the main developers.
- Bigger HTTP Header Buffer
- Exception if Header is anyway exceeded.
- Linebreaks on HTTP Request fixed to standard.
- Only stop header reading on \r\n\r\n and no longer on \n\n\n\n
- Simplyfied the code to stop if buffer could not be filled.
- Handle special case if buffer has length 0, like specified in the Java API
- Socket will no longer fill the buffer completely
2015-12-26 11:58:40 +01:00
Joel Dice
9abba8fe24 add bootimage-test option to makefile
This option specifies that the test classes should be AOT-compiled
along with the class library, which allows us to test that everything
works in AOT-compiled form as well as JIT-compiled form.  This is
primarily motivated by the need to test d906db6 (support for
AOT-compilation of Java 8 lambda expressions).

Note that I had to tweak Misc because it tested something that
couldn't be done in an AOT build without a lot of extra work, and
SystemClassLoader.getPackage because it was returning null when the
requested package could not be populated with JAR manifest metadata.
Technically, we probably *should* return null for packages that don't
exist at all (in the sense that no classes have been loaded from such
a package), but tracking that kind of thing seems like more trouble
than it's worth unless someone complains about it.
2015-10-19 15:10:53 -06:00
Joshua Warner
e2f2ed68f0 ignore leading / for files on Windows (fixes #452) 2015-09-02 08:31:30 -06:00
Joel Dice
66712a8cff add invokedynamic support to interpreter 2015-08-06 17:22:14 -06:00
Joel Dice
8a7944d25c add support for openjdk=$JDK8_HOME
All tests pass for the process=compile build.  Next step: process=interpret.
2015-08-06 13:30:18 -06:00
Joel Dice
2465459079 implement basic Java 8 lambda support
The two big pieces here are basic invokedynamic support and a working
version of LambdaMetaFactory.metafactory.  The latter works by
dynamically building a synthetic class with three methods: a static
factory method, a constructor for the factory method to call, and a
method to satisfy the requested interface which defers to the
specified MethodHandle.

This work relies heavily on Avian's specific MethodType and
MethodHandle implementations, which provide extra, non-standard
features to make code generation easier.  That means we'll probably
need to use Avian's versions of java.lang.invoke.* even when building
with the OpenJDK or Android class libraries.
2015-08-06 13:30:18 -06:00
joshuawarner32@gmail.com
792684b935 first pass at minimal invokedynamic support for Java 8 lambdas
This is a bunch of commits squashed into one per Josh's request.

add dynamicTable field

add invokedynamic instruction

add defaultDynamic bootimage field

add dummy invokedynamic support in bootimage-generator

add defaultDynamic thunk

check dynamicTable offset

comment defaultDynamicThunk to fix unused function

comment defaultDynamicThunk to fix unused function

add dynamicTable / dynamicIndex stuff

comment dynamicIndex and dynamicTable

add invokedynamic instruction impl

stub out addDynamic

unstub addDynamic

don't allow tail calls in invokedynamic

implement stub JVM_GetTemporaryDirectory method

(build broken) begin add InvokeDynamicTest

Revert "(build broken) begin add InvokeDynamicTest"

This reverts commit 77f9c54e32ac66d0803eeab93e4a10d3541987a8.

add InternalError

add URLClassPath.c for openjdk-src builds

implement stub JVM_KnownToNotExist and JVM_GetResourceLookupCache methods

intercept open0 / open for openjdk

add basic java/lang/invoke stubs

remove non-public java/lang/invoke classes

fix invokedynamic example building

<wip debugging>
2015-08-06 13:30:05 -06:00
tarotanaka0
85463c693e fix for -Wunused-parameters 2015-06-04 23:01:19 +09:00
tarotanaka0
7e1debef44 fix JNI stack alignment 2015-06-04 16:02:29 +09:00
BCG
5bd8d2759e Switched test harness from calling avian.FormatString to use java.lang.String.format() instead 2015-03-17 12:34:45 -04:00
BCG
a8bed52097 Added java.util.Formatter implementation. Basic/common formats work,
such as %s, %d, %x... also width, left justify, zerofill flags are
implemented. Many of the other formats do not work, see the comments in
avian.FormatString javadoc and look for FIXME and TODO items for more
information on features that are known to not work correctly.
2015-03-17 01:08:07 -04:00
Joel Dice
c6f7129c27 ensure ci.sh exits with error when any test fails
As explained in
http://stackoverflow.com/questions/25794905/why-does-set-e-true-false-true-not-exit,
"set -e" will only cause the script to exit if the failing command is
"unhandled".  The fancy || and && shortcuts we were using to run some
of the tests caused bash to think we were handling the errors, which
isn't what we wanted.
2015-03-16 16:47:24 -06:00
Joel Dice
d6c9d3c2d0 disable openjdk=... and jdk tests if arch flag specified
These combinations generally won't work, since the JAVA_HOME JDK will
tend to match the native, default architecture, not the one specified.
2015-03-13 15:28:14 -06:00
Joel Dice
7a4cae0dde load bootstrap classes in findInterfaceMethod
In afbd4ff, I made a low-risk, but very specific fix for a more
general problem: "bootstrap" classes (i.e. classes which the VM has
built-in knowledge of) need to be loaded from the classpath before any
of their methods are called.  Based on recent testing, I found there were
more cases than I previously thought where the VM tries to call methods on
"unloaded" bootstrap classes, so we needed a more general solution to
the problem.

This commit addresses it by closing the last (known) loophole by which
methods might be called on bootstrap classes: invokeinterface, and its
helper method findInterfaceMethod.  The fix is to check for bootstrap
classes in findInterfaceMethod and load the full versions if
necessary.  This process may lead to garbage collection and/or thrown
exceptions, which made me nervous about cases of direct or indirect
calls to findInterfaceMethod not expecting those events, which is why
I hadn't used that approach earlier.  However, it turns out there were
only a few places that made non-GC-safe calls to findInterfaceMethod,
and a bit of code rearrangement fixed that.
2015-02-06 13:51:32 -07:00
Joel Dice
afbd4ff303 fix crash when calling Class.getDeclaredMethods using the OpenJDK class library
This method ends up defering to JVM_GetClassDeclaredMethods, which
creates an array of java.lang.reflect.Method instances and then
calling getName on each one through the java.lang.reflect.Member
interface.  However, Method is a "bootstrap" class, meaning the VM has
built-in knowledge of it and includes a tentative version built-in but
must load the real version from the classpath at runtime before
invoking methods on it.  Normally this happens naturally when Method
instances are created in Java code, but here we're creating them in
the VM instead, which doesn't automatically cause the real class to be
loaded.  So we must do so explicitly.
2015-01-22 12:02:28 -07:00
Joel Dice
8ee7e8124a fix broken interpreter build due to out-of-order class initialization
When we initialize the vtables for bootstrap Java classes such as
java.lang.NullPointerException (i.e. classes which the VM has built-in
knowledge of), we assign the superclass's vtable to any class which
has no declared virtual methods of its own.  However, that vtable will
be null if we haven't initialized the superclass yet.  Therefore, we
must order this process such that no class is initialized until after
all its superclasses.
2015-01-15 17:13:46 -07:00
Seth Goings
eafec7e850 Add mac publishing + testing
- Move apt calls to ci script
2015-01-05 12:01:56 -07:00
Seth Goings
ab83e852ff Remove Travis CI matrix for now (best utilized when/if we have other platforms/arches) 2015-01-02 16:52:15 -07:00
Seth Goings
f717d87e8c Add better publishing intended for Travis + establish packages for windows/linux builds 2015-01-02 16:37:22 -07:00
Ilya Mizus
ecce49be5d Added some tests for class types 2014-10-11 23:50:53 +04:00
Joel Dice
1575b901d4 implement Class.getEnclosingClass 2014-10-09 08:01:42 -06:00
Joel Dice
fbcdfd6dec Merge remote-tracking branch 'dicej/android-upgrade' 2014-10-08 13:41:50 -06: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
Joel Dice
b406e9c2ed Merge remote-tracking branch 'origin/master' into android-upgrade 2014-09-24 10:59:39 -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
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
32ef5da55a don't try to run CMake on Cygwin
We've still got some bugs to work out with CMake on Cygwin, so we
disable it for now.
2014-08-19 11:47:34 -06:00
Joshua Warner
1753eed778 skip bootimage tests with 'openjdk' but no 'openjdk-src' flags 2014-08-17 13:56:54 -06:00
Joshua Warner
9c415cbf09 disable irrelevant openjdk target when openjdk is passed as a flag 2014-08-15 15:29:53 -06:00
Joshua Warner
374a39651b allow passing flags to ci.sh script 2014-07-30 14:15:22 -06:00
Mike Jensen
9c4d7c68bd Adding a couple simple tests around the StringBuilder 2014-07-24 13:47:31 -06:00
Joshua Warner
73bbbe4812 add partial cmake build to ci.sh 2014-07-24 09:42:42 -06:00
Seth Goings
b717f86e47 Parallelize travis builds 2014-07-23 18:24:17 -06:00
Joel Dice
cae4b49005 fix heapdump=true build 2014-07-16 15:51:48 -06: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
Joel Dice
1b83ef7eb3 only wrap Exceptions in ExceptionInInitializerErrors, not Errors 2014-07-10 13:43:10 -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
codespotx
26547f08b6 test/MemoryRamp.java: demonstrate slow multithreaded memory access. 2014-06-04 18:00:06 +02:00
Joshua Warner
a35e47b6fb add 'mode=debug bootimage=true' test to ci.sh 2014-05-31 11:18:42 -06:00