mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
Merge branch 'master' of ssh://oss.readytalk.com/var/local/git/avian
This commit is contained in:
commit
8549ab856e
@ -12,6 +12,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "jni.h"
|
||||
|
@ -93,6 +93,11 @@ public class StringBuffer implements CharSequence {
|
||||
return this;
|
||||
}
|
||||
|
||||
public synchronized StringBuffer insert(int i, int v) {
|
||||
sb.insert(i, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public synchronized StringBuffer delete(int start, int end) {
|
||||
sb.delete(start, end);
|
||||
return this;
|
||||
|
@ -154,6 +154,10 @@ public class StringBuilder implements CharSequence {
|
||||
return insert(i, new String(new char[] { c }, 0, 1, false));
|
||||
}
|
||||
|
||||
public StringBuilder insert(int i, int v) {
|
||||
return insert(i, String.valueOf(v));
|
||||
}
|
||||
|
||||
public StringBuilder delete(int start, int end) {
|
||||
if (start >= end) {
|
||||
return this;
|
||||
|
@ -45,6 +45,12 @@ public abstract class Calendar {
|
||||
fields[field] = value;
|
||||
}
|
||||
|
||||
public void set(int year, int month, int date) {
|
||||
set(YEAR, year);
|
||||
set(MONTH, month);
|
||||
set(DAY_OF_MONTH, date);
|
||||
}
|
||||
|
||||
public void setTime(Date date) {
|
||||
time = date.getTime();
|
||||
}
|
||||
|
81
makefile
81
makefile
@ -3,18 +3,15 @@ MAKEFLAGS = -s
|
||||
name = avian
|
||||
version = 0.1.1
|
||||
|
||||
build-arch = $(shell uname -m)
|
||||
ifeq ($(build-arch),i586)
|
||||
build-arch = i386
|
||||
endif
|
||||
ifeq ($(build-arch),i686)
|
||||
build-arch = i386
|
||||
endif
|
||||
build-arch = $(shell uname -m | sed 's/^i.86$$/i386/')
|
||||
|
||||
build-platform = $(shell uname -s | tr [:upper:] [:lower:])
|
||||
build-platform = \
|
||||
$(shell uname -s | tr [:upper:] [:lower:] \
|
||||
| sed 's/^mingw32.*$$/mingw32/' \
|
||||
| sed 's/^cygwin.*$$/cygwin/')
|
||||
|
||||
arch = $(build-arch)
|
||||
platform = $(build-platform)
|
||||
platform = $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
|
||||
|
||||
ifeq ($(platform),windows)
|
||||
arch = i386
|
||||
@ -41,12 +38,13 @@ cxx = $(build-cxx)
|
||||
cc = $(build-cc)
|
||||
ar = ar
|
||||
ranlib = ranlib
|
||||
dlltool = dlltool
|
||||
objcopy = objcopy
|
||||
vg = nice valgrind --num-callers=32 --db-attach=yes --freelist-vol=100000000
|
||||
vg += --leak-check=full --suppressions=valgrind.supp
|
||||
db = gdb --args
|
||||
javac = javac
|
||||
jar = jar
|
||||
javac = "$(JAVA_HOME)/bin/javac"
|
||||
jar = "$(JAVA_HOME)/bin/jar"
|
||||
strip = :
|
||||
strip-all = --strip-all
|
||||
|
||||
@ -55,17 +53,19 @@ rdynamic = -rdynamic
|
||||
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self
|
||||
|
||||
common-cflags = $(warnings) -fno-rtti -fno-exceptions \
|
||||
-I$(JAVA_HOME)/include -idirafter $(src) -I$(native-build) \
|
||||
"-I$(JAVA_HOME)/include" -idirafter $(src) -I$(native-build) \
|
||||
-D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
|
||||
-DBOOT_CLASSPATH=\"[classpathJar]\"
|
||||
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
||||
-I$(JAVA_HOME)/include/linux -I$(src) -pthread
|
||||
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
|
||||
|
||||
cflags = $(build-cflags)
|
||||
|
||||
common-lflags = -lm -lz -lstdc++
|
||||
|
||||
build-lflags =
|
||||
|
||||
lflags = $(common-lflags) -lpthread -ldl
|
||||
|
||||
system = posix
|
||||
@ -80,6 +80,8 @@ so-suffix = .so
|
||||
|
||||
shared = -shared
|
||||
|
||||
native-path = echo
|
||||
|
||||
ifeq ($(arch),i386)
|
||||
object-arch = i386
|
||||
object-format = elf32-i386
|
||||
@ -87,8 +89,7 @@ ifeq ($(arch),i386)
|
||||
endif
|
||||
|
||||
ifeq ($(platform),darwin)
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
||||
-I$(JAVA_HOME)/include/linux -I$(src)
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
||||
rdynamic =
|
||||
strip-all = -S -x
|
||||
@ -98,25 +99,37 @@ ifeq ($(platform),darwin)
|
||||
endif
|
||||
|
||||
ifeq ($(platform),windows)
|
||||
inc = $(root)/win32/include
|
||||
lib = $(root)/win32/lib
|
||||
inc = "$(root)/win32/include"
|
||||
lib = "$(root)/win32/lib"
|
||||
|
||||
system = windows
|
||||
object-format = pe-i386
|
||||
|
||||
so-prefix =
|
||||
so-suffix = .dll
|
||||
exe-suffix = .exe
|
||||
|
||||
cxx = i586-mingw32msvc-g++
|
||||
cc = i586-mingw32msvc-gcc
|
||||
dlltool = i586-mingw32msvc-dlltool
|
||||
ar = i586-mingw32msvc-ar
|
||||
ranlib = i586-mingw32msvc-ranlib
|
||||
objcopy = i586-mingw32msvc-objcopy
|
||||
|
||||
rdynamic = -Wl,--export-dynamic
|
||||
lflags = -L$(lib) $(common-lflags) -lws2_32 -mwindows -mconsole
|
||||
cflags = $(common-cflags) -I$(inc)
|
||||
|
||||
ifeq (,$(filter mingw32 cygwin,$(build-platform)))
|
||||
cxx = i586-mingw32msvc-g++
|
||||
cc = i586-mingw32msvc-gcc
|
||||
dlltool = i586-mingw32msvc-dlltool
|
||||
ar = i586-mingw32msvc-ar
|
||||
ranlib = i586-mingw32msvc-ranlib
|
||||
objcopy = i586-mingw32msvc-objcopy
|
||||
else
|
||||
build-cflags = $(common-cflags) \
|
||||
"-I$(JAVA_HOME)/include/win32" -I$(src) -mthreads
|
||||
ifeq ($(build-platform),cygwin)
|
||||
build-lflags += -mno-cygwin
|
||||
build-cflags += -mno-cygwin
|
||||
lflags += -mno-cygwin
|
||||
cflags += -mno-cygwin
|
||||
native-path = cygpath -m
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(mode),debug)
|
||||
@ -214,9 +227,9 @@ generator-objects = \
|
||||
generator = $(native-build)/generator
|
||||
|
||||
static-library = $(native-build)/lib$(name).a
|
||||
executable = $(native-build)/$(name)
|
||||
executable = $(native-build)/$(name)${exe-suffix}
|
||||
dynamic-library = $(native-build)/$(so-prefix)$(name)$(so-suffix)
|
||||
executable-dynamic = $(native-build)/$(name)-dynamic
|
||||
executable-dynamic = $(native-build)/$(name)-dynamic${exe-suffix}
|
||||
|
||||
classpath-sources = $(shell find $(classpath) -name '*.java')
|
||||
classpath-classes = \
|
||||
@ -255,7 +268,7 @@ vg: build
|
||||
|
||||
.PHONY: test
|
||||
test: build
|
||||
/bin/bash $(test)/test.sh 2>/dev/null \
|
||||
/bin/sh $(test)/test.sh 2>/dev/null \
|
||||
$(executable) $(mode) "$(flags)" \
|
||||
$(call class-names,$(test-build),$(test-classes))
|
||||
|
||||
@ -293,7 +306,7 @@ $(classpath-dep): $(classpath-sources)
|
||||
@echo "compiling classpath classes"
|
||||
@mkdir -p $(dir $(@))
|
||||
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
|
||||
$(shell make -s --no-print-directory $(classpath-classes))
|
||||
$(shell $(MAKE) -s --no-print-directory $(classpath-classes))
|
||||
@touch $(@)
|
||||
|
||||
$(test-build)/%.class: $(test)/%.java
|
||||
@ -303,7 +316,7 @@ $(test-dep): $(test-sources)
|
||||
@echo "compiling test classes"
|
||||
@mkdir -p $(dir $(@))
|
||||
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
|
||||
$(shell make -s --no-print-directory $(test-classes))
|
||||
$(shell $(MAKE) -s --no-print-directory $(test-classes))
|
||||
@touch $(@)
|
||||
|
||||
define compile-object
|
||||
@ -333,7 +346,7 @@ $(boot-object): $(boot-source)
|
||||
$(build)/classpath.jar: $(classpath-dep)
|
||||
(wd=$$(pwd); \
|
||||
cd $(classpath-build); \
|
||||
$(jar) c0f $${wd}/$(@) $$(find . -name '*.class'))
|
||||
$(jar) c0f "$$($(native-path) "$${wd}/$(@)")" $$(find . -name '*.class'))
|
||||
|
||||
$(binaryToMacho): $(src)/binaryToMacho.cpp
|
||||
$(cxx) $(^) -o $(@)
|
||||
@ -347,7 +360,7 @@ else
|
||||
(wd=$$(pwd); \
|
||||
cd $(build); \
|
||||
$(objcopy) -I binary classpath.jar \
|
||||
-O $(object-format) -B $(object-arch) $${wd}/$(@))
|
||||
-O $(object-format) -B $(object-arch) "$${wd}/$(@)")
|
||||
endif
|
||||
|
||||
$(generator-objects): $(native-build)/%.o: $(src)/%.cpp
|
||||
@ -371,7 +384,7 @@ $(executable): \
|
||||
@echo "linking $(@)"
|
||||
ifeq ($(platform),windows)
|
||||
$(dlltool) -z $(@).def $(^)
|
||||
$(dlltool) -k -d $(@).def -e $(@).exp
|
||||
$(dlltool) -d $(@).def -e $(@).exp
|
||||
$(cc) $(@).exp $(^) $(lflags) -o $(@)
|
||||
else
|
||||
$(cc) $(^) $(rdynamic) $(lflags) -o $(@)
|
||||
@ -392,5 +405,5 @@ $(executable-dynamic): $(driver-dynamic-object) $(dynamic-library)
|
||||
|
||||
$(generator): $(generator-objects)
|
||||
@echo "linking $(@)"
|
||||
$(build-cc) $(^) -o $(@)
|
||||
$(build-cc) $(^) $(build-lflags) -o $(@)
|
||||
|
||||
|
78
readme.txt
78
readme.txt
@ -10,6 +10,21 @@ on Mac OS X:
|
||||
$ export JAVA_HOME=/Library/Java/Home
|
||||
$ make
|
||||
$ build/darwin-i386-compile-fast/avian -cp build/test Hello
|
||||
|
||||
on Windows (MSYS):
|
||||
|
||||
$ export JAVA_HOME="C:/Program Files/Java/jdk1.6.0_07"
|
||||
$ make
|
||||
$ build/windows-i386-compile-fast/avian -cp build/test Hello
|
||||
|
||||
on Windows (Cygwin):
|
||||
|
||||
$ export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.6.0_07"
|
||||
$ make
|
||||
$ build/windows-i386-compile-fast/avian -cp build/test Hello
|
||||
|
||||
Adjust JAVA_HOME according to your system, but be sure to use forward
|
||||
slashes in the path.
|
||||
|
||||
|
||||
Introduction
|
||||
@ -40,10 +55,6 @@ Avian can currently target the following platforms:
|
||||
Win32 (i386)
|
||||
Mac OS X (i386)
|
||||
|
||||
The Win32 port may be built on Linux using a MinGW cross compiler and
|
||||
build environment. Builds on MSYS or Cygwin are not yet supported,
|
||||
but patches to enable them are welcome.
|
||||
|
||||
|
||||
Building
|
||||
--------
|
||||
@ -60,20 +71,11 @@ Build requirements include:
|
||||
Earlier versions of some of these packages may also work but have not
|
||||
been tested.
|
||||
|
||||
If you are cross-compiling for Windows, you may find it useful to use
|
||||
our win32 repository: (run this from the directory containing the
|
||||
avian directory)
|
||||
|
||||
$ git clone git://oss.readytalk.com/win32.git
|
||||
|
||||
This gives you the Windows JNI headers, zlib headers and library, and
|
||||
a few other useful libraries like OpenSSL and libjpeg.
|
||||
|
||||
The build is directed by a single makefile and may be influenced via
|
||||
certain flags described below.
|
||||
|
||||
$ make platform={linux,windows,darwin} arch={i386,x86_64} \
|
||||
process={compile,interpret} mode={debug,debug-fast,fast}
|
||||
process={compile,interpret} mode={debug,debug-fast,fast,small}
|
||||
|
||||
* platform - the target platform
|
||||
default: output of $(uname -s | tr [:upper:] [:lower:])
|
||||
@ -89,6 +91,33 @@ certain flags described below.
|
||||
* process - choice between pure interpreter or JIT compiler
|
||||
default: compile
|
||||
|
||||
If you are compiling for Windows, you may either cross-compile using
|
||||
MinGW or build natively on Windows under MSYS or Cygwin.
|
||||
|
||||
Installing MSYS:
|
||||
|
||||
1. Download and install the current MinGW and MSYS packages from
|
||||
mingw.org, selecting the C and C++ compilers when prompted. Use the
|
||||
post-install script to create the filesystem link to the compiler.
|
||||
|
||||
2. Download GNU Make 3.81 from the MSYS download page
|
||||
(make-3.81-MSYS-1.0.11-2.tar.bz2) and extract the tar file into
|
||||
e.g. c:/msys/1.0.
|
||||
|
||||
Installing Cygwin:
|
||||
|
||||
1. Download and run setup.exe from cygwin.com, installing the base
|
||||
system and these packages: make, gcc-mingw-g++, and (optionally)
|
||||
git.
|
||||
|
||||
You may also find our win32 repository useful: (run this from the
|
||||
directory containing the avian directory)
|
||||
|
||||
$ git clone git://oss.readytalk.com/win32.git
|
||||
|
||||
This gives you the Windows JNI headers, zlib headers and library, and
|
||||
a few other useful libraries like OpenSSL and libjpeg.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
@ -102,6 +131,9 @@ Embedding
|
||||
The following series of commands illustrates how to produce a
|
||||
stand-alone executable out of a Java application using Avian.
|
||||
|
||||
Note: if you are building on Cygwin, add -mno-cygwin to each of the
|
||||
compile and link commands below.
|
||||
|
||||
Step 1: Build Avian, create a new directory, and populate it with the
|
||||
VM object files and bootstrap classpath jar.
|
||||
|
||||
@ -223,7 +255,17 @@ main(int ac, const char** av)
|
||||
return exitCode;
|
||||
}
|
||||
EOF
|
||||
$ g++ -I$JAVA_HOME/include -c main.cpp -o main.o
|
||||
|
||||
on Linux:
|
||||
$ g++ -I$JAVA_HOME/include -I$JAVA_HOME/include/linux \
|
||||
-D_JNI_IMPLEMENTATION_ -c main.cpp -o main.o
|
||||
|
||||
on Mac OS X:
|
||||
$ g++ -I$JAVA_HOME/include -D_JNI_IMPLEMENTATION_ -c main.cpp -o main.o
|
||||
|
||||
on Windows:
|
||||
$ g++ -I$JAVA_HOME/include -I$JAVA_HOME/include/win32 \
|
||||
-D_JNI_IMPLEMENTATION_ -c main.cpp -o main.o
|
||||
|
||||
|
||||
Step 5: Link the objects produced above to produce the final
|
||||
@ -237,3 +279,9 @@ on Mac OS X:
|
||||
$ g++ -rdynamic *.o -ldl -lpthread -lz -o hello -framework CoreFoundation
|
||||
$ strip -S -x hello
|
||||
|
||||
on Windows:
|
||||
$ dlltool -z hello.def *.o
|
||||
$ dlltool -d hello.def -e hello.exp
|
||||
$ g++ hello.exp *.o -L../../win32/lib -lmingwthrd -lm -lz -lws2_32 \
|
||||
-mwindows -mconsole -o hello.exe
|
||||
$ strip --strip-all hello.exe
|
||||
|
@ -167,8 +167,7 @@ resolveNativeMethod2(Thread* t, object method)
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
// on windows, we also try the _%s@%d variant, since the SWT
|
||||
// libraries use it.
|
||||
// on windows, we also try the _%s@%d and %s@%d variants
|
||||
unsigned footprint = methodParameterFootprint(t, method) + 1;
|
||||
if (methodFlags(t, method) & ACC_STATIC) {
|
||||
++ footprint;
|
||||
@ -186,6 +185,12 @@ resolveNativeMethod2(Thread* t, object method)
|
||||
if (p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
// one more try without the leading underscore
|
||||
p = ::resolveNativeMethod(t, undecorated + 1, decorated + 1);
|
||||
if (p) {
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user