Commit Graph

70 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
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
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
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
0800508b4e move Runtime.freeMemory and totalMemory to builtin.cpp
This allows them to be shared between the Avian and Android class
library builds.

This commit also disables the URL test in Misc.java on Android, since
it's known to fail, and we still want to know whether the other tests
pass.
2014-05-10 18:56:04 -06:00
Joel Dice
a41efb76c5 avoid NPE in URL.set when file is null 2014-04-23 15:51:57 -06:00
Joel Dice
1ed3de08fa fix Misc test failures
The Misc test was failing when run as "make input=Misc run" since
test-flags did not include $(build)/extra-dir in the class library,
leading the ClassLoader.getResources test to fail.

Also, the UnknownHostException test was not reliable -- some ISPs
(mine included) return DNS matches for bogus hostnames, defaulting to
the IP address of a webserver intended to help users with name
resolution problems.  That's dumb, I know, but I'm guessing I'm not
the only person with a dumb ISP, and it seems better to just remove
the test than make people think Avian is broken when it's really just
their DNS server that's broken.
2014-04-20 19:11:15 -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
Joel Dice
1735a7976a do not omit calls to empty methods which may trigger class initialization
There's a small optimization in compileDirectInvoke which tries to
avoid generating calls to empty methods.  However, this causes
problems for code which uses such a call to ensure a class is
initialized -- if we omit that call, the class may not be
initialized and any side effects of that initialization may not
happen when the program expects them to.

This commit ensures that the compiler only omits empty method calls
when the target class does not need initialization.  It also removes
commented-out code in classpath-openjdk.cpp which was responsible for
loading libmawt proactively; that was a hack to get JogAmp to work
before we understood what the real problem was.
2014-02-10 08:40:14 -07:00
Joel Dice
59d5bbbb1a throw UnknownHostException if host is not found in InetAddress.getByName 2013-12-18 10:43:11 -07:00
Joel Dice
5f40c1642e don't throw UnknownHostException from InetAddress.getByName("0.0.0.0")
0.0.0.0 means any local interface, which is commonly used by servers
which wish to listen on all interfaces.
2013-12-18 10:12:10 -07:00
Johannes Schindelin
a2feec0bab Add a pseudo-integration test for getResources()
This adds an extra class path element to the VM running the unit tests,
writes files with identical file names into both directories and then
verifies that SystemClassLoader#getResources can find them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:53:02 -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
3309a9f4ad ensure that array classes implement Cloneable and Serializable in bootimage build 2013-03-15 13:26:18 -06: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
c6ac66e45a fix bug in isAssignableFrom such that primitive array types were considered to be subclasses of the Object array type 2012-02-27 18:16:01 -07:00
Joel Dice
51c56c1b3c add PrintStream.print[ln] overloads for primitives and char arrays 2011-01-20 08:26:56 -07:00
Joel Dice
4f23601b56 fix corner cases which led to crashes in JIT compiler
Compiling the entire OpenJDK class library into a bootimage revealed
some corner cases which broke the compiler, including synchronization
in a finally block and gotos targeting the first instruction of an
unsynchronized method.
2010-11-26 12:36:43 -07:00
Joel Dice
75de0a621b fix windows.cpp MySystem::now 2010-11-07 12:35:31 -07:00
Joel Dice
d0a6096eb0 add support for accessing embedded JARs as if they were directories
This allows OpenJDK to access time zone data which is normally found
under java.home, but which we must embed in the executable itself to
create a self-contained build.  The VM intercepts various file
operations, looking for paths which start with a prefix specified by
the avian.embed.prefix property and redirecting those operations to an
embedded JAR.

For example, if avian.embed.prefix is "/avian-embedded", and code
calls File.exists() with a path of
"/avian-embedded/javahomeJar/foo.txt", the VM looks for a function
named javahomeJar via dlsym, calls the function to find the memory
region containing the embeded JAR, and finally consults the JAR to see
if the file "foo.txt" exists.
2010-11-05 13:18:28 -06:00
Joel Dice
1d4b54a9f6 fix failure to add abstract virtuals to class with no declared virtuals 2010-09-25 16:35:18 -06:00
Joel Dice
45476eb591 fix handling of volatile longs and doubles on PowerPC
We were miscompiling methods which contained getfield, getstatic,
putfield, or putstatic instructions for volatile 64-bit primitives on
32-bit PowerPC due to not noticing that values in registers are clobbered
across function calls.

The solution is to create a separate Compiler::Operand instance for each
object monitor reference before and after the function call to avoid
confusing the compiler.  To avoid duplicate entries in the constant pool,
we add code look for and, if found, reuse any existing entry for the same
constant.
2010-01-27 17:46:04 -07:00
Joel Dice
20c1ea08e6 remove a test from Misc.java since it's been moved to Strings.java 2009-08-14 08:53:33 -06:00
Joel Dice
8410e1d683 ensure reads and writes of volatile 64-bit fields are atomic 2009-03-03 18:02:11 -07:00
Joel Dice
a1ec71423e Merge branch 'master' into powerpc
Conflicts:

	makefile
	src/assembler.h
	src/binaryToMacho.cpp
	src/compile.cpp
	src/compiler.cpp
	src/x86.cpp
2009-02-09 16:22:01 -07:00
Joel Dice
29616c4abc freeze target site when using temporary in maybeMove 2009-02-08 18:58:33 -07:00
Joel Dice
54ad7c4e98 tolerate ConstantValue attributes on non-static fields, since the compiler ensures that they are initialized in any constructors for that class (i.e., the VM does not need to do anything special to initialize them) 2009-01-10 12:25:52 -07:00
Joel Dice
b23f7374e9 don't steal sites in pickJunctionSite 2008-12-20 17:45:52 -07:00
Joel Dice
d50febe088 various control-flow related bugfixes 2008-12-11 18:09:36 -07:00
Joel Dice
cae5202be0 split Misc.java into four separate files 2008-11-10 17:07:15 -07:00
Joel Dice
e0e827596e make Long.parseLong more efficient 2008-08-29 11:37:53 -06:00
Joel Dice
a016eeaba0 fix Long.toString for Long.MIN_VALUE case 2008-07-13 17:54:44 -06:00
Joel Dice
107ac01304 fix addCR and subtractCR for cases of 64-bit constants on amd64 2008-07-02 08:52:35 -06:00
Joel Dice
e9c37f5ffd add more tests of operations on longs to Misc.java 2008-06-12 11:00:43 -06:00
Joel Dice
fc8c5a2ea9 fix a few bugs revealed by ProGuard optimizations, including too-early constant propagation during array loads and stores 2008-06-10 08:49:13 -06:00
Joel Dice
3326aafdac various 32-bit fixes 2008-05-22 11:15:18 -06:00
Joel Dice
21cb1c3c8f remove Event::validate, since it is no longer needed and actually causes trouble 2008-05-20 16:47:53 -06:00
Joel Dice
36dbf1ad14 fix another local variable caching bug 2008-05-20 15:24:10 -06:00
Joel Dice
d604efd8f5 fix local variable caching bug 2008-05-20 13:11:42 -06:00
Joel Dice
c9f06933e2 test long addition and subtraction in Misc, as well as multidimensional array creation 2008-05-18 09:45:52 -06:00
Joel Dice
b6b84af123 various bugfixes 2008-05-17 21:32:14 -06:00
Joel Dice
7f72a6469d more register marshalling bugfixes; simple swt apps now run on amd64 2008-05-15 17:19:23 -06:00
Joel Dice
bbd1ee5540 various register marshalling bugfixes 2008-05-15 14:00:57 -06:00
Joel Dice
bf08cc4c53 fix array bounds checks 2008-04-30 11:47:25 -06:00
Joel Dice
918193fa60 fix 32-bit right unsigned shifts on amd64 2008-04-30 11:15:21 -06:00
Joel Dice
e2b24263a2 various bugfixes 2008-04-30 09:44:17 -06:00
Joel Dice
1b5f14d847 re-enable tests in Misc and get them working 2008-04-28 09:53:48 -06:00
Joel Dice
d6c3b2327f bugfixes; enums test now succeeds 2008-04-20 13:35:36 -06:00
Joel Dice
525f733171 Merge branch 'master' into compiler
Conflicts:

	src/compile.cpp
	src/compiler.cpp
	src/compiler.h
2008-04-13 13:48:20 -06:00