Commit 140993e4 authored by Mark's avatar Mark
parents 6a1cc61f fc96a46e
......@@ -487,14 +487,17 @@ Returns the Maven specific string for the artifact "
(ignore-errors
(jss:new 'aether.repository.RemoteRepository id type url))))
(defparameter *default-repository*
"http://repo1.maven.org/maven2/")
(defvar *default-repository*
"https://repo1.maven.org/maven2/"
"URI of default remote Maven repository")
(defun add-repository (repository)
(ensure-remote-repository :repository repository))
(defparameter *maven-remote-repository* nil
"The remote repository used by the Maven Aether embedder.")
"Reference to remote repository used by the Maven Aether
embedder.")
(defun ensure-remote-repository (&key
(force nil)
(repository *default-repository* repository-p))
......@@ -549,8 +552,10 @@ in Java CLASSPATH representation."
(when *maven-http-proxy*
(#"setProxy" r (make-proxy)))
r)))
(let* ((node
(#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
(let* ((collect-result (#"collectDependencies" (ensure-repository-system)
(ensure-session) collect-request))
(node
(#"getRoot" collect-result))
(dependency-request
;;; pre Maven-3.3.x
#+nil
......
......@@ -28,6 +28,7 @@
;;;; Maven
#:*mvn-libs-directory*
#:*maven-http-proxy*
#:*default-repository*
#:make-remote-repository
#:*maven-remote-repository*
#:resolve-multiple-maven-dependencies
......
(defsystem abcl-build-tests
:version "2.0.1"
:description "Test ABCL build system."
:defsystem-depends-on (prove-asdf)
:depends-on (abcl-build
prove)
:perform (test-op (op c)
(symbol-call :prove-asdf 'run-test-system c))
:components ((:module package
:pathname "build/t/"
:components ((:file "package")))
(:module build
:depends-on (package)
:components ((:module build
:pathname "build/t/"
:components ((:test-file "util")
(:test-file "install")
......
(in-package :abcl/build)
(defun maven-zip-uri ()
#p"http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip")
#p"https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip")
(defun xdg/mvn-executable ()
(xdg/executable (maven-zip-uri) "bin/mvn"))
......
(in-package :abcl/build/t)
(in-package :cl-user)
(if (not (ignore-errors (asdf:find-system :abcl)))
(prove:diag "Unable to find 'abcl.asd'.~&Enable ASDF to find 'abcl.asd' by adding symlink to ~~/common-lisp/ to ABCL source directory.")
......
(in-package :abcl/build/t)
(in-package :cl-user)
(prove:plan 1)
(prove:ok
......
(in-package :abcl/build/t)
(in-package :cl-user)
(prove:plan 1)
(prove:ok
......@@ -6,7 +6,7 @@
"Testing ABCL-specific Ant installation of Maven into XDG hierarchy…")
(if (not (ignore-errors (asdf:find-system :abcl)))
(prove:diag "Unable to find 'abcl.asd'.~&Enable ASDF to find 'abcl.asd' by adding symlink to ~~/common-lisp/ to ABCL source directory.")
(prove:diag "Unable to find 'abcl.asd'.~&Enable ASDF to find 'abcl.asd' by adding symlink to ~~/common-lisp/ to ABCL source directory.")
(let ((pom (asdf:system-relative-pathname :abcl "pom.xml")))
(prove:ok (abcl/build:mvn/call pom "install")
(format nil "Testing invocation of private Maven on root ABCL POM at~&~2,t~a…"
......
(defpackage :abcl/build/t
(:use :cl))
(in-package :abcl/build/t)
(in-package :cl-user)
(prove:plan 1)
(prove:is-type (abcl/build:possible-executable-names "java")
......
......@@ -85,11 +85,15 @@ public final class Bignum extends LispInteger
@Override
public Object javaInstance(Class c) {
if (BigInteger.class.equals(c)) {
return value;
}
return error(new TypeError("Cannot convert Bignum to " + c.getName()));
if (c == Byte.class || c == byte.class)
return Byte.valueOf((byte)value.intValue());
if (c == Short.class || c == short.class)
return Short.valueOf((short)value.intValue());
if (c == Integer.class || c == int.class)
return Integer.valueOf(value.intValue());
if (c == Long.class || c == long.class)
return Long.valueOf((long)value.longValue());
return javaInstance();
}
......
......@@ -236,11 +236,9 @@ public final class DoubleFloat extends LispObject
@Override
public Object javaInstance(Class c)
{
if (Double.class.equals(c) || double.class.equals(c)) {
return Double.valueOf(value);
}
return error(new TypeError("Cannot convert DoubleFloat to " + c.getName()));
if (c == Float.class || c == float.class)
return Float.valueOf((float)value);
return javaInstance();
}
@Override
......
......@@ -76,12 +76,13 @@ public final class Fixnum extends LispInteger
@Override
public Object javaInstance(Class c)
{
if (Long.class.equals(c) || long.class.equals(c))
if (c == Byte.class || c == byte.class)
return Byte.valueOf((byte)value);
if (c == Short.class || c == short.class)
return Short.valueOf((short)value);
if (c == Long.class || c == long.class)
return Long.valueOf((long)value);
if (Integer.class.equals(c) || int.class.equals(c))
return Integer.valueOf(value);
return error(new TypeError("Cannot convert Fixnum to " + c.getName()));
return javaInstance();
}
@Override
......
......@@ -57,9 +57,7 @@ public final class JavaObject extends LispObject {
/**
* Constructs a Java Object with the given intended class, used to access
* the object reflectively. If the class represents a primitive type,
* the corresponding wrapper type is used instead (and a narrowing conversion
* done if necessary).
*
* the corresponding wrapper type is used instead.
* @throws ClassCastException if the object is not an instance of the
* intended class.
*/
......@@ -67,47 +65,18 @@ public final class JavaObject extends LispObject {
if(obj != null && intendedClass == null) {
intendedClass = obj.getClass();
}
if(obj != null && !intendedClass.equals(obj.getClass())) {
if(intendedClass != null) {
intendedClass = Java.maybeBoxClass(intendedClass);
if(!intendedClass.isInstance(obj)) {
if (obj instanceof Number) {
if (intendedClass.equals(Byte.class)) {
obj = ((Number) obj).byteValue();
} else if (intendedClass.equals(Short.class)) {
obj = ((Number) obj).shortValue();
} else if (intendedClass.equals(Integer.class)) {
obj = ((Number) obj).intValue();
} else if (intendedClass.equals(Long.class)) {
obj = ((Number) obj).longValue();
} else if (intendedClass.equals(Character.class)) {
obj = Character.valueOf((char) ((Number) obj).intValue());
} else if (intendedClass.equals(Float.class)) {
obj = ((Number) obj).floatValue();
} else if (intendedClass.equals(Double.class)) {
obj = ((Number) obj).doubleValue();
} else {
throw new ClassCastException(obj + " can not be cast to " + intendedClass);
}
} else if (obj instanceof Character) {
char c = ((Character) obj).charValue();
if (intendedClass.equals(Byte.class)) {
obj = (byte) c;
} else if (intendedClass.equals(Short.class)) {
obj = (short) c;
} else if (intendedClass.equals(Integer.class)) {
obj = (int) c;
} else if (intendedClass.equals(Long.class)) {
obj = (long) c;
} else if (intendedClass.equals(Float.class)) {
obj = (float) c;
} else if (intendedClass.equals(Double.class)) {
obj = (double) c;
} else {
throw new ClassCastException(obj + " can not be cast to " + intendedClass);
}
} else {
throw new ClassCastException(obj + " can not be cast to " + intendedClass);
if (intendedClass.equals(java.lang.Byte.class)
&& obj instanceof java.lang.Number) {
// Maps any number to two's complement 8bit byte representation
// ??? Is this a reasonable thing?
this.obj = ((java.lang.Number)obj).byteValue();
this.intendedClass = intendedClass;
return;
}
throw new ClassCastException(obj + " can not be cast to " + intendedClass);
}
}
this.obj = obj;
......@@ -309,9 +278,6 @@ public final class JavaObject extends LispObject {
} else {
c = Java.maybeBoxClass(c);
if (c.isAssignableFrom(intendedClass) || c.isInstance(obj)) {
// By using isAssignableFrom() we are assured that we don't do any narrowing
// here (use (jcoerce) for that, or from java .getInstance(obj, class))
// XXX In the case that c.isInstance(obj) should we then
// "fix" the intendedClass field with the (presumably)
// narrower type of 'obj'?
......@@ -323,61 +289,6 @@ public final class JavaObject extends LispObject {
// representations.
return obj;
} else {
// Still need to do widening conversions here...
if (obj instanceof Byte) {
if (c.equals(Short.class)) {
return ((Byte) obj).shortValue();
} else if (c.equals(Integer.class)) {
return ((Byte) obj).intValue();
} else if (c.equals(Long.class)) {
return ((Byte) obj).longValue();
} else if (c.equals(Float.class)) {
return ((Byte) obj).floatValue();
} else if (c.equals(Double.class)) {
return ((Byte) obj).doubleValue();
}
} else if (obj instanceof Short) {
if (c.equals(Integer.class)) {
return ((Short) obj).intValue();
} else if (c.equals(Long.class)) {
return ((Short) obj).longValue();
} else if (c.equals(Float.class)) {
return ((Short) obj).floatValue();
} else if (c.equals(Double.class)) {
return ((Short) obj).doubleValue();
}
} else if (obj instanceof Integer) {
if (c.equals(Long.class)) {
return ((Integer) obj).longValue();
} else if (c.equals(Float.class)) {
return ((Integer) obj).floatValue();
} else if (c.equals(Double.class)) {
return ((Integer) obj).doubleValue();
}
} else if (obj instanceof Long) {
if (c.equals(Float.class)) {
return ((Long) obj).floatValue();
} else if (c.equals(Double.class)) {
return ((Long) obj).doubleValue();
}
} else if (obj instanceof Float) {
if (c.equals(Double.class)) {
return ((Float) obj).doubleValue();
}
// nothing that doesn't potentially narrow for double
// } else if (obj instanceof Double) {
} else if (obj instanceof Character) {
if (c.equals(Integer.class)) {
return (int) ((Character) obj).charValue();
} else if (c.equals(Long.class)) {
return (long) ((Character) obj).charValue();
} else if (c.equals(Float.class)) {
return (float) ((Character) obj).charValue();
} else if (c.equals(Double.class)) {
return (double) ((Character) obj).charValue();
}
}
return error(new TypeError(intendedClass.getName() + " is not assignable to " + c.getName()));
}
}
......
......@@ -200,14 +200,7 @@ public final class LispCharacter extends LispObject
@Override
public Object javaInstance(Class c)
{
if (Integer.class.equals(c) || int.class.equals(c))
return (int) Character.valueOf(value);
if (Long.class.equals(c) || long.class.equals(c))
return (long) Character.valueOf(value);
if (Character.class.equals(c) || char.class.equals(c))
return Character.valueOf(value);
return error(new TypeError("Cannot convert LispCharacter to " + c.getName()));
return javaInstance();
}
@Override
......
......@@ -241,12 +241,9 @@ public final class SingleFloat extends LispObject
@Override
public Object javaInstance(Class c)
{
if (Float.class.equals(c) || float.class.equals(c))
if (c == Float.class || c == float.class)
return Float.valueOf(value);
if (Double.class.equals(c) || double.class.equals(c))
return Double.valueOf(value);
return error(new TypeError("Cannot convert SingleFloat to " + c.getName()));
return javaInstance();
}
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment