Skip to content

Commit 8af174a

Browse files
authored
Merge pull request #80 from JuliaInterop/julia-1.0
Julia 1.0
2 parents df789b1 + d6e79b0 commit 8af174a

File tree

9 files changed

+67
-68
lines changed

9 files changed

+67
-68
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*~
22
.juliahistory
3-
.DS_Store
3+
.DS_Store
4+
Manifest.toml

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ language: julia
22
os:
33
- linux
44
julia:
5-
- 0.6
65
- 0.7
6+
- 1.0
7+
- nightly
8+
9+
matrix:
10+
allow_failures:
11+
- julia_version: nightly
12+
713
notifications:
814
email: false

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
julia 0.6
1+
julia 0.7
22
DataStructures
3-
Compat 0.65
43
@windows WinReg

appveyor.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0\
5-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
6-
JAVA_HOME: C:\Program Files\Java\jdk1.7.0\
7-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
8-
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0\
9-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
10-
JAVA_HOME: C:\Program Files\Java\jdk1.7.0\
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
116

7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# # Uncomment the following lines to allow failures on nightly julia
12+
# # (tests will run but not make your overall status red)
1213
matrix:
1314
allow_failures:
14-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
15-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
15+
- julia_version: nightly
1616

1717
branches:
1818
only:
@@ -26,19 +26,18 @@ notifications:
2626
on_build_status_changed: false
2727

2828
install:
29-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
30-
# Download most recent Julia Windows binary
31-
- ps: (new-object net.webclient).DownloadFile(
32-
$env:JULIA_URL,
33-
"C:\projects\julia-binary.exe")
34-
# Run installer silently, output to C:\projects\julia
35-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3630

3731
build_script:
38-
# Need to convert from shallow to complete for Pkg.clone to work
39-
- IF EXIST .git\shallow (git fetch --unshallow)
40-
- C:\projects\julia\bin\julia -e "versioninfo();
41-
Pkg.clone(pwd(), \"JavaCall\"); Pkg.build(\"JavaCall\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4234

4335
test_script:
44-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"JavaCall\")"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
38+
39+
# # Uncomment to support code coverage upload. Should only be enabled for packages
40+
# # which would have coverage gaps without running on Windows
41+
# on_success:
42+
# - echo "%JL_CODECOV_SCRIPT%"
43+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

doc/methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Calling instance methods uses the `jcall` function, with an instance of the `Jav
7474
```julia
7575
jcall(gurl, "getHost", JString,()) #"wwww.google.com"
7676
innerObj=jcall(outerObj, "createrInnerObject", jinner,())
77-
jcall(innerObj, "innerMethod", Void,()) #Prints "In Inner class Method"
77+
jcall(innerObj, "innerMethod", Nothing,()) #Prints "In Inner class Method"
7878
```
7979

8080
##Calling Array Methods

src/JavaCall.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@ export JavaObject, JavaMetaClass,
66
getname, getclass, listmethods, getreturntype, getparametertypes, classforname,
77
narrow
88

9-
using Compat, Compat.Dates
9+
# using Compat, Compat.Dates
1010

11-
using Compat.Sys: iswindows, islinux, isunix, isapple
11+
# using Sys: iswindows, islinux, isunix, isapple
1212

1313
import DataStructures: OrderedSet
14+
import Libdl
15+
using Dates
1416

15-
if VERSION < v"0.7-"
16-
using Compat: @warn
17-
import Base: isnull
18-
Base.finalizer(f::Function, o) = Base.finalizer(o, f)
19-
else
20-
using Libdl
21-
end
22-
23-
@static if iswindows()
17+
@static if Sys.iswindows()
2418
using WinReg
2519
end
2620

src/convert.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ unsafe_convert(::Type{Ptr{Nothing}}, cls::JavaMetaClass) = cls.ptr
3030

3131
# Get the JNI/C type for a particular Java type
3232
function real_jtype(rettype)
33-
if issubtype(rettype, JavaObject) || issubtype(rettype, Array) || issubtype(rettype, JavaMetaClass)
33+
if rettype <: JavaObject || rettype <: Array || rettype <: JavaMetaClass
3434
jnitype = Ptr{Nothing}
3535
else
3636
jnitype = rettype
@@ -324,10 +324,13 @@ function narrow(obj::JavaObject)
324324
return convert(JavaObject{Symbol(t)}, obj)
325325
end
326326

327-
# TODO replace once iterate is available in Compat
328-
Base.start(itr::JavaObject) = true
329-
function Base.next(itr::JavaObject, state)
330-
o = jcall(itr, "next", @jimport(java.lang.Object), ())
331-
return (narrow(o), state)
327+
has_next(itr::JavaObject) = (jcall(itr, "hasNext", jboolean, ()) == JNI_TRUE)
328+
329+
function Base.iterate(itr::JavaObject, state=nothing)
330+
if has_next(itr)
331+
o = jcall(itr, "next", @jimport(java.lang.Object), ())
332+
return (narrow(o), state)
333+
else
334+
return nothing
335+
end
332336
end
333-
Base.done(itr::JavaObject, state) = (jcall(itr, "hasNext", jboolean, ()) == JNI_FALSE)

src/jvm.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function javahome_winreg()
3434
end
3535
end
3636

37-
@static isunix() ? (global const libname = "libjvm") : (global const libname = "jvm")
37+
@static Sys.isunix() ? (global const libname = "libjvm") : (global const libname = "jvm")
3838

3939
function findjvm()
4040
javahomes = Any[]
@@ -43,12 +43,12 @@ function findjvm()
4343
if haskey(ENV,"JAVA_HOME")
4444
push!(javahomes,ENV["JAVA_HOME"])
4545
else
46-
@static iswindows() ? ENV["JAVA_HOME"] = javahome_winreg() : nothing
47-
@static iswindows() ? push!(javahomes, ENV["JAVA_HOME"]) : nothing
46+
@static Sys.iswindows() ? ENV["JAVA_HOME"] = javahome_winreg() : nothing
47+
@static Sys.iswindows() ? push!(javahomes, ENV["JAVA_HOME"]) : nothing
4848
end
4949

5050
if isfile("/usr/libexec/java_home")
51-
push!(javahomes,chomp(readstring(`/usr/libexec/java_home`)))
51+
push!(javahomes,chomp(read(`/usr/libexec/java_home`, String)))
5252
end
5353

5454
if isdir("/usr/lib/jvm/default-java/")
@@ -57,12 +57,12 @@ function findjvm()
5757

5858
push!(libpaths, pwd())
5959
for n in javahomes
60-
@static if iswindows()
60+
@static if Sys.iswindows()
6161
push!(libpaths, joinpath(n, "bin", "server"))
6262
push!(libpaths, joinpath(n, "jre", "bin", "server"))
6363
push!(libpaths, joinpath(n, "bin", "client"))
6464
end
65-
@static if islinux()
65+
@static if Sys.islinux()
6666
if Sys.WORD_SIZE==64
6767
push!(libpaths, joinpath(n, "jre", "lib", "amd64", "server"))
6868
push!(libpaths, joinpath(n, "lib", "amd64", "server"))
@@ -76,16 +76,16 @@ function findjvm()
7676
push!(libpaths, joinpath(n, "lib", "server"))
7777
end
7878

79-
ext = @static iswindows() ? "dll" : (@static isapple() ? "dylib" : "so")
79+
ext = @static Sys.iswindows() ? "dll" : (@static Sys.isapple() ? "dylib" : "so")
8080
ext = "."*ext
8181

8282
try
8383
for n in libpaths
8484
libpath = joinpath(n,libname*ext);
8585
if isfile(libpath)
86-
if iswindows()
86+
if Sys.iswindows()
8787
bindir = dirname(dirname(libpath))
88-
m = filter(x -> ismatch(r"msvcr(?:.*).dll",x), readdir(bindir))
88+
m = filter(x -> occursin(r"msvcr(?:.*).dll",x), readdir(bindir))
8989
Libdl.dlopen(joinpath(bindir,m[1]))
9090
end
9191
global libjvm = Libdl.dlopen(libpath)
@@ -124,14 +124,14 @@ struct JavaVMInitArgs
124124
end
125125

126126

127-
@static isunix() ? (const sep = ":") : nothing
128-
@static iswindows() ? (const sep = ";") : nothing
127+
@static Sys.isunix() ? (const sep = ":") : nothing
128+
@static Sys.iswindows() ? (const sep = ";") : nothing
129129
cp = OrderedSet{String}()
130130
opts = OrderedSet{String}()
131131

132132
function addClassPath(s::String)
133133
if isloaded()
134-
warn("JVM already initialised. This call has no effect")
134+
@warn("JVM already initialised. This call has no effect")
135135
return
136136
end
137137
if s==""; return; end

test/runtests.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
using Compat, Compat.Test
1+
using Test
22
using JavaCall
33

4-
if VERSION v"0.7-"
5-
import Pkg
6-
import Dates
7-
using Base.GC: gc
8-
end
4+
import Dates
5+
using Base.GC: gc
96

107

118
JavaCall.init(["-Djava.class.path=$(@__DIR__)"])
@@ -33,8 +30,8 @@ T = @jimport Test
3330
@test "Hello Java"==jcall(T, "testString", JString, (JString,), "Hello Java")
3431
@test Float64(10.02) == jcall(T, "testDouble", jdouble, (jdouble,), 10.02) #Comparing exact float representations hence ==
3532
@test Float32(10.02) == jcall(T, "testFloat", jfloat, (jfloat,), 10.02)
36-
@test realmax(jdouble) == jcall(T, "testDouble", jdouble, (jdouble,), realmax(jdouble))
37-
@test realmax(jfloat) == jcall(T, "testFloat", jfloat, (jfloat,), realmax(jfloat))
33+
@test floatmax(jdouble) == jcall(T, "testDouble", jdouble, (jdouble,), floatmax(jdouble))
34+
@test floatmax(jfloat) == jcall(T, "testFloat", jfloat, (jfloat,), floatmax(jfloat))
3835
c=JString(C_NULL)
3936
@test isnull(c)
4037
@test "" == jcall(T, "testString", JString, (JString,), c)
@@ -123,9 +120,9 @@ end
123120

124121
@testset "inner_classes_1" begin
125122
TestInner = @jimport(Test$TestInner)
126-
Test = @jimport(Test)
127-
t=Test(())
128-
inner = TestInner((Test,), t)
123+
JTest = @jimport(Test)
124+
t=JTest(())
125+
inner = TestInner((JTest,), t)
129126
@test jcall(inner, "innerString", JString, ()) == "from inner"
130127
@test jfield(@jimport(java.lang.Math), "E", jdouble) == 2.718281828459045
131128
@test jfield(@jimport(java.lang.Math), "PI", jdouble) == 3.141592653589793

0 commit comments

Comments
 (0)