Remove Java reflection/interop support

This is not used in the context of Gerrit Code Review but is a
non-trivial amount of code to continue to track. Drop the code
to simplify the system.

Change-Id: I5ce320970e549fc18d4e9195e7aa98b6ed352c4c
diff --git a/src/builtin/PRED_$begin_sync_2.java b/src/builtin/PRED_$begin_sync_2.java
deleted file mode 100644
index 6f42d35..0000000
--- a/src/builtin/PRED_$begin_sync_2.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-/**
- * <code>'$begin_sync'/2</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.2
- */
-class PRED_$begin_sync_2 extends BlockPredicate {
-    Term arg1, arg2;
-
-    public PRED_$begin_sync_2(Term a1, Term a2, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.setB0();
-	Term a1, a2;
-	a1 = arg1;
-	a2 = arg2;
-
-	Object o = null;
-	Operation code = null;
-
-	// 1st. argument
-	a1 = a1.dereference();
-	if (a1.isVariable())
-	    throw new PInstantiationException(this, 1);
-	if (! a1.isJavaObject())
-	    throw new IllegalTypeException(this, 1, "java", a1);
-	o = ((JavaObjectTerm)a1).object();
-	// 2nd. argument
-	a2 = a2.dereference();
-	if (! a2.isVariable())
-	    throw new IllegalTypeException(this, 2, "variable", a1);
-	((VariableTerm) a2).bind(new JavaObjectTerm(this), engine.trail);
-	//
-	code = cont;
-	this.outOfScope = false;
-	this.outOfLoop  = false;
-	engine.trail.push(new OutOfLoop(this));
-	main_loop:while(true) {
-	    synchronized (o) {
-		while (! outOfScope) {
-		    if (engine.halt != 0) {
-			    break main_loop;
-		    }
-		    if (engine.control.isEngineStopped())
-			break main_loop;
-		    if (outOfLoop)
-			break main_loop;
-		    code = code.exec(engine);
-		}
-
-	    }
-	    while (outOfScope) {
-		if (engine.halt != 0) {
-			break main_loop;
-		}
-		if (engine.control.isEngineStopped())
-		    break main_loop;
-		if (outOfLoop)
-		    break main_loop;
-		code = code.exec(engine);
-	    }
-
-	}
-	return code;
-    }
-}
diff --git a/src/builtin/PRED_$end_sync_1.java b/src/builtin/PRED_$end_sync_1.java
deleted file mode 100644
index 8ca20b0..0000000
--- a/src/builtin/PRED_$end_sync_1.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-/**
- * <code>'$end_sync'/1</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.0
- */
-class PRED_$end_sync_1 extends Predicate.P1 {
-    public PRED_$end_sync_1(Term a1, Operation cont) {
-	arg1 = a1;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.setB0();
-	Term a1;
-	a1 = arg1;
-
-	a1 = a1.dereference();
-	if (! a1.isJavaObject())
-	    throw new IllegalTypeException(this, 1, "java", a1);
-	Object obj = ((JavaObjectTerm)a1).object();
-	if (! (obj instanceof PRED_$begin_sync_2))
-	    throw new SystemException("a1 must be an object of PRED_$begin_sync_2: " + this);
-	PRED_$begin_sync_2 p = ((PRED_$begin_sync_2) obj);
-	p.outOfScope = true;
-	engine.trail.push(new OutOfScope(p));
-	return cont;
-    }
-}
diff --git a/src/builtin/PRED_java_constructor0_2.java b/src/builtin/PRED_java_constructor0_2.java
deleted file mode 100644
index e76e22c..0000000
--- a/src/builtin/PRED_java_constructor0_2.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_constructor0/2</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_constructor0_2 extends JavaPredicate {
-    Term arg1, arg2;
-
-    public PRED_java_constructor0_2(Term a1, Term a2, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2;
-	a1 = arg1;
-	a2 = arg2;
-
-	Class clazz = null;
-	Object instance = null;
-	int arity;
-	Constructor[] constrs = null;
-	Term[] pArgs = null;
-	Object[] jArgs = null;
-	Constructor c = null;
-
-	try {
-	    // 2nd. argument (unbound variable)
-	    a2 = a2.dereference();
-	    if (! a2.isVariable())
-		throw new IllegalTypeException(this, 2, "variable", a2);
-	    // 1st. argument (atom or callable term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable())
-		throw new PInstantiationException(this, 1);
-	    if (!a1.isSymbol() && !a1.isStructure())
-		throw new IllegalTypeException(this, 1, "callable", a1);
-	    if (a1.isSymbol()) { // No argument constructor
-		clazz = Class.forName(((SymbolTerm)a1).name());
-		instance = clazz.newInstance();
-		if (! a2.unify(toPrologTerm(instance), engine.trail))
-		    return engine.fail();
-		return cont;
-	    } 
-	    // Parameterized constructor
-	    clazz = Class.forName(((StructureTerm)a1).name());
-	    arity  = ((StructureTerm)a1).arity();
-	    constrs = clazz.getConstructors();
-	    if (constrs.length == 0)
-		throw new ExistenceException(this, 1, "constructor", a1, "");
-	    pArgs  = ((StructureTerm)a1).args();
-	    jArgs  = new Object[arity];
-	    for (int i=0; i<arity; i++) {
-		pArgs[i] = pArgs[i].dereference();
-		if (! pArgs[i].isJavaObject())
-		    pArgs[i] = new JavaObjectTerm(pArgs[i]);
-		jArgs[i] = pArgs[i].toJava();
-	    }
-	    for (int i=0; i<constrs.length; i++) {
-		if (checkParameterTypes(constrs[i].getParameterTypes(), pArgs)) {
-		    try {
-			c = constrs[i]; 
-			//c.setAccessible(true);
-			instance = c.newInstance(jArgs);
-			break;    // Succeeds to create new instance
-		    } catch (Exception e) {
-			c = null; // Back to loop
-		    }
-		}
-	    }
-	    if (c == null)
-		throw new ExistenceException(this, 1, "constructor", a1, "");
-	    if (! a2.unify(toPrologTerm(instance), engine.trail)) 
-		return engine.fail();
-	    return cont;
-	} catch (ClassNotFoundException e) {    // Class.forName(..)
-	    throw new JavaException(this, 1, e);
-	} catch (InstantiationException e) {    // Class.forName(..) or Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	} catch (IllegalAccessException e) {    // Class.forName(..) or Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	} catch (SecurityException e) {         // Class.getConstructors()
-	    throw new JavaException(this, 1, e);
-	} catch (IllegalArgumentException e) {  // Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_conversion_2.java b/src/builtin/PRED_java_conversion_2.java
deleted file mode 100644
index 329fcc2..0000000
--- a/src/builtin/PRED_java_conversion_2.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import com.googlecode.prolog_cafe.lang.*;
-import java.util.List;
-/**
- * <code>java_conversion/2</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_conversion_2 extends Predicate.P2 {
-    public PRED_java_conversion_2(Term a1, Term a2, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.setB0();
-	Term a1, a2;
-	a1 = arg1;
-	a2 = arg2;
-
-	a1 = a1.dereference();
-	a2 = a2.dereference();
-	if (a1.isVariable()) { // a1 = var
-	    if (a2.isJavaObject()) { // a1 = var /\ a2 = java
-		((VariableTerm)a1).bind(inverseConversion(((JavaObjectTerm)a2).object()), engine.trail);
-	    } else { // a1 = var /\ a2 = nonjava
-		((VariableTerm)a1).bind(a2, engine.trail);
-	    }
-	} else if (! a2.isVariable()) { // a1 = nonvar /\ a2 = nonvar
-	    throw new IllegalTypeException(this, 2, "variable", a2);
-	} else { // a1 = nonvar /\ a2 = var
-	    // (a1 = java \/  a1 = str \/ a1 = clo) /\ a2 = var
-	    if (a1.isJavaObject() || a1.isStructure() || a1.isClosure()) {
-		((VariableTerm)a2).bind(a1, engine.trail);
-	    } else { // a1 != java /\ a1 != str /\ a1 != clo /\ a2 = var
-		((VariableTerm)a2).bind(new JavaObjectTerm(a1.toJava()), engine.trail);
-	    }
-	}
-	return cont;
-    }
-
-    protected Term inverseConversion(Object o) {
-	if (o == null) {
-	    throw new EvaluationException(this, 2, "undefined");
-	} else if (o instanceof Byte    || 
-		   o instanceof Short   ||
-		   o instanceof Integer ||
-		   o instanceof Long) {
-	    return new IntegerTerm(((Number)o).intValue());
-	} else if (o instanceof Float || 
-		   o instanceof Double) {
-	    return new DoubleTerm(((Number)o).doubleValue());
-	} else if (o instanceof String) {
-	    return SymbolTerm.create((String) o);
-	} else if (o instanceof List) {
-	    List v = (List) o;
-	    Term t = Prolog.Nil;
-	    for(int i= v.size(); i>0; i--) {
-		t = new ListTerm(inverseConversion(v.get(i-1)), t);
-	    }
-	    return t;
-	}
-	return new JavaObjectTerm(o);
-    }
-}
diff --git a/src/builtin/PRED_java_declared_constructor0_2.java b/src/builtin/PRED_java_declared_constructor0_2.java
deleted file mode 100644
index 64e8836..0000000
--- a/src/builtin/PRED_java_declared_constructor0_2.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_declared_constructor0/2</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_declared_constructor0_2 extends JavaPredicate {
-    Term arg1, arg2;
-
-    public PRED_java_declared_constructor0_2(Term a1, Term a2, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2;
-	a1 = arg1;
-	a2 = arg2;
-
-	Class clazz = null;
-	Object instance = null;
-	int arity;
-	Constructor[] constrs = null;
-	Term[] pArgs = null;
-	Object[] jArgs = null;
-	Constructor c = null;
-
-	// 2nd. argument (unbound variable)
-	a2 = a2.dereference();
-	if (! a2.isVariable())
-	    throw new IllegalTypeException(this, 2, "variable", a2);
-	// 1st. argument (atom or callable term)
-	try {
-	    a1 = a1.dereference();
-	    if (a1.isVariable())
-		throw new PInstantiationException(this, 1);
-	    if (!a1.isSymbol() && !a1.isStructure())
-		throw new IllegalTypeException(this, 1, "callable", a1);
-	    if (a1.isSymbol()) { // No argument constructor
-		clazz = Class.forName(((SymbolTerm)a1).name());
-		c = clazz.getDeclaredConstructor();
-		if (c == null)
-		    throw new ExistenceException(this, 1, "constructor", a1, "");
-		c.setAccessible(true);
-		instance = c.newInstance();
-		if (! a2.unify(toPrologTerm(instance), engine.trail))
-		    return engine.fail();
-		return cont;
-	    } 
-	    // Parameterized constructor
-	    clazz = Class.forName(((StructureTerm)a1).name());
-	    arity  = ((StructureTerm)a1).arity();
-	    constrs = clazz.getDeclaredConstructors();
-	    if (constrs.length == 0)
-		throw new ExistenceException(this, 1, "constructor", a1, "");
-	    pArgs  = ((StructureTerm)a1).args();
-	    jArgs  = new Object[arity];
-	    for (int i=0; i<arity; i++) {
-		pArgs[i] = pArgs[i].dereference();
-		if (! pArgs[i].isJavaObject())
-		    pArgs[i] = new JavaObjectTerm(pArgs[i]);
-		jArgs[i] = pArgs[i].toJava();
-	    }
-	    for (int i=0; i<constrs.length; i++) {
-		if (checkParameterTypes(constrs[i].getParameterTypes(), pArgs)) {
-		    try {
-			c = constrs[i]; 
-			c.setAccessible(true);
-			instance = c.newInstance(jArgs);
-			break;    // Succeeds to create new instance
-		    } catch (Exception e) {
-			c = null; // Back to loop
-		    }
-		}
-	    }
-	    if (c == null)
-		throw new ExistenceException(this, 1, "constructor", a1, "");
-	    if (! a2.unify(toPrologTerm(instance), engine.trail))
-		return engine.fail();
-	    return cont;
-	} catch (ClassNotFoundException e) {    // Class.forName(..)
-	    throw new JavaException(this, 1, e);
-	} catch (InstantiationException e) {    // Class.forName(..) or Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	} catch (IllegalAccessException e) {    // Class.forName(..) or Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchMethodException e) {     // Class.getDeclaredConstructor()
-	    throw new JavaException(this, 1, e);
-	} catch (SecurityException e) {         // Class.getDeclaredConstructors()
-	    throw new JavaException(this, 1, e);
-	} catch (IllegalArgumentException e) {  // Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	} catch (InvocationTargetException e) { // Constructor.newInstance()
-	    throw new JavaException(this, 1, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_declared_method0_3.java b/src/builtin/PRED_java_declared_method0_3.java
deleted file mode 100644
index 37877df..0000000
--- a/src/builtin/PRED_java_declared_method0_3.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_declared_method0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_declared_method0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_declared_method0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class clazz = null;
-	Object instance = null;
-	Method[] methods = null;
-	Method m = null;
-	Object value = null;
-	int arity;
-	Term[] pArgs = null;
-	Object[] jArgs = null;
-	String methodName = null;
-
-	// 3rd. argument (unbound variable)
-	a3 = a3.dereference();
-	if (! a3.isVariable())
-	    throw new IllegalTypeException(this, 3, "variable", a3);
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom or callable term)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (a2.isSymbol()) {    // No argument method
-		m = clazz.getDeclaredMethod(((SymbolTerm)a2).name());
-		m.setAccessible(true);
-		value = m.invoke(instance);
-	    } else if (a2.isStructure()) { // Parameterized method
-		methodName = ((StructureTerm)a2).name();
-		arity      = ((StructureTerm)a2).arity();
-		methods = clazz.getDeclaredMethods();
-		if (methods.length == 0)
-		    throw new ExistenceException(this, 2, "method", a2, "");
-		pArgs = ((StructureTerm)a2).args();
-		jArgs = new Object[arity];
-		for (int i=0; i<arity; i++) {
-		    pArgs[i] = pArgs[i].dereference();
-		    if (! pArgs[i].isJavaObject())
-			pArgs[i] = new JavaObjectTerm(pArgs[i]);
-		    jArgs[i] = pArgs[i].toJava();
-		}
-		for (int i=0; i<methods.length; i++) {
-		    if (methods[i].getName().equals(methodName) 
-			&&  checkParameterTypes(methods[i].getParameterTypes(), pArgs)) {
-			try {
-			    m = methods[i];
-			    m.setAccessible(true);
-			    value = m.invoke(instance, jArgs); 
-			    break;     // Succeeds to invoke the method
-			} catch (Exception e) {
-			    m = null;  // Back to loop
-			}
-		    }
-		}
-		if (m == null)
-		    throw new ExistenceException(this, 2, "method", a2, "");
-	    } else {
-		throw new IllegalTypeException(this, 2, "callable", a2);
-	    }
-	    if (value == null)
-		return cont;
-	    if (! a3.unify(toPrologTerm(value), engine.trail))
-		return engine.fail();
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchMethodException e) {     // Class.getDeclaredMethod
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getDeclaredMethods
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (InvocationTargetException e) { // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Method.invoke
-	    throw new JavaException(this, 2, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_get_declared_field0_3.java b/src/builtin/PRED_java_get_declared_field0_3.java
deleted file mode 100644
index 0e8265f..0000000
--- a/src/builtin/PRED_java_get_declared_field0_3.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_get_declared_field0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_get_declared_field0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_get_declared_field0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class  clazz = null;
-	Object instance = null;
-	Field  field = null;
-	Object value = null;
-
-	// 3rd. argument (unbound variable)
-	a3 = a3.dereference();
-	if (! a3.isVariable())
-	    throw new IllegalTypeException(this, 3, "variable", a3);
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {	
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (! a2.isSymbol()) {
-		throw new IllegalTypeException(this, 2, "atom", a2);
-	    }
-	    field = clazz.getDeclaredField(((SymbolTerm)a2).name());
-	    field.setAccessible(true);
-	    value = field.get(instance);
-	    // 3rd. argument
-	    if (value == null)
-		return cont;
-	    if (! a3.unify(toPrologTerm(value), engine.trail)) 
-		return engine.fail();
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchFieldException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_get_field0_3.java b/src/builtin/PRED_java_get_field0_3.java
deleted file mode 100644
index ff4d084..0000000
--- a/src/builtin/PRED_java_get_field0_3.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_get_field0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_get_field0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_get_field0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class  clazz = null;
-	Object instance = null;
-	Field  field = null;
-	Object value = null;
-
-	// 3rd. argument (unbound variable)
-	a3 = a3.dereference();
-	if (! a3.isVariable())
-	    throw new IllegalTypeException(this, 3, "variable", a3);
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {	
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (! a2.isSymbol()) {
-		throw new IllegalTypeException(this, 2, "atom", a2);
-	    }
-	    field = clazz.getField(((SymbolTerm)a2).name());
-	    value = field.get(instance);
-	    // 3rd. argument
-	    if (value == null)
-		return cont;
-	    if (! a3.unify(toPrologTerm(value), engine.trail)) 
-		return engine.fail();
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchFieldException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_method0_3.java b/src/builtin/PRED_java_method0_3.java
deleted file mode 100644
index 5fc6fad..0000000
--- a/src/builtin/PRED_java_method0_3.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_method0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_method0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_method0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class clazz = null;
-	Object instance = null;
-	Method[] methods = null;
-	Method m = null;
-	Object value = null;
-	int arity;
-	Term[] pArgs = null;
-	Object[] jArgs = null;
-	String methodName = null;
-
-	// 3rd. argument (unbound variable)
-	a3 = a3.dereference();
-	if (! a3.isVariable())
-	    throw new IllegalTypeException(this, 3, "variable", a3);
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom or callable term)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (a2.isSymbol()) {    // No argument method
-		m = clazz.getMethod(((SymbolTerm)a2).name());
-		//m.setAccessible(true);
-		value = m.invoke(instance);
-	    } else if (a2.isStructure()) { // Parameterized method
-		methodName = ((StructureTerm)a2).name();
-		arity      = ((StructureTerm)a2).arity();
-		methods = clazz.getMethods();
-		if (methods.length == 0)
-		    throw new ExistenceException(this, 2, "method", a2, "");
-		pArgs = ((StructureTerm)a2).args();
-		jArgs = new Object[arity];
-		for (int i=0; i<arity; i++) {
-		    pArgs[i] = pArgs[i].dereference();
-		    if (! pArgs[i].isJavaObject())
-			pArgs[i] = new JavaObjectTerm(pArgs[i]);
-		    jArgs[i] = pArgs[i].toJava();
-		}
-		for (int i=0; i<methods.length; i++) {
-		    if (methods[i].getName().equals(methodName) 
-			&&  checkParameterTypes(methods[i].getParameterTypes(), pArgs)) {
-			try {
-			    m = methods[i];
-			    //m.setAccessible(true);
-			    value = m.invoke(instance, jArgs); 
-			    break;     // Succeeds to invoke the method
-			} catch (Exception e) {
-			    m = null;  // Back to loop
-			}
-		    }
-		}
-		if (m == null)
-		    throw new ExistenceException(this, 2, "method", a2, "");
-	    } else {
-		throw new IllegalTypeException(this, 2, "callable", a2);
-	    }
-	    if (value == null)
-		return cont;
-	    if (! a3.unify(toPrologTerm(value), engine.trail))
-		return engine.fail();
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchMethodException e) {     // Class.getDeclaredMethod
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getDeclaredMethods
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (InvocationTargetException e) { // Method.invoke
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Method.invoke
-	    throw new JavaException(this, 2, e);
-	}
-    }
-
-    private Term toPrologTerm(Object obj) {
-	if (Term.instanceOfTerm(obj))
-	    return (Term)obj;
-	else 
-	    return new JavaObjectTerm(obj);
-    }
-}
diff --git a/src/builtin/PRED_java_set_declared_field0_3.java b/src/builtin/PRED_java_set_declared_field0_3.java
deleted file mode 100644
index 451851e..0000000
--- a/src/builtin/PRED_java_set_declared_field0_3.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_set_declared_field0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_set_declared_field0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_set_declared_field0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class  clazz = null;
-	Object instance = null;
-	Field  field = null;
-	Object value = null;
-
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {	
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (! a2.isSymbol()) {
-		throw new IllegalTypeException(this, 2, "atom", a2);
-	    }
-	    field = clazz.getDeclaredField(((SymbolTerm)a2).name());
-	    // 3rd. argument (term)
-	    a3 = a3.dereference();
-	    if (a3.isJavaObject())
-		value = a3.toJava();
-	    else
-		value = a3;
-	    field.setAccessible(true);
-	    field.set(instance, value);
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchFieldException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	}
-    }
-}
-
-
diff --git a/src/builtin/PRED_java_set_field0_3.java b/src/builtin/PRED_java_set_field0_3.java
deleted file mode 100644
index 133d8ff..0000000
--- a/src/builtin/PRED_java_set_field0_3.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.googlecode.prolog_cafe.builtin;
-import  com.googlecode.prolog_cafe.lang.*;
-import java.lang.reflect.*;
-/**
- * <code>java_set_field0/3</code>
- * @author Mutsunori Banbara (banbara@kobe-u.ac.jp)
- * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
- * @version 1.1
- */
-public class PRED_java_set_field0_3 extends JavaPredicate {
-    Term arg1, arg2, arg3;
-
-    public PRED_java_set_field0_3(Term a1, Term a2, Term a3, Operation cont) {
-	arg1 = a1;
-	arg2 = a2;
-	arg3 = a3;
-	this.cont = cont;
-    }
-
-    public Operation exec(Prolog engine) {
-        engine.requireFeature(Prolog.Feature.JAVA_REFLECTION, this, arg1);
-        engine.setB0();
-
-	Term a1, a2, a3;
-	a1 = arg1;
-	a2 = arg2;
-	a3 = arg3;
-
-	Class  clazz = null;
-	Object instance = null;
-	Field  field = null;
-	Object value = null;
-
-	try {
-	    // 1st. argument (atom or java term)
-	    a1 = a1.dereference();
-	    if (a1.isVariable()) {	
-		throw new PInstantiationException(this, 1);
-	    } else if (a1.isSymbol()){      // class
-		clazz = Class.forName(((SymbolTerm)a1).name());
-	    } else if (a1.isJavaObject()) { // instance
-		instance = ((JavaObjectTerm)a1).object();
-		clazz = ((JavaObjectTerm)a1).getClazz();
-	    } else {
-		throw new IllegalTypeException(this, 1, "atom_or_java", a1);
-	    }
-	    // 2nd. argument (atom)
-	    a2 = a2.dereference();
-	    if (a2.isVariable()) {
-		throw new PInstantiationException(this, 2);
-	    } else if (! a2.isSymbol()) {
-		throw new IllegalTypeException(this, 2, "atom", a2);
-	    }
-	    field = clazz.getField(((SymbolTerm)a2).name());
-	    // 3rd. argument (term)
-	    a3 = a3.dereference();
-	    if (a3.isJavaObject())
-		value = a3.toJava();
-	    else
-		value = a3;
-	    field.set(instance, value);
-	    return cont; 
-	} catch (ClassNotFoundException e) {    // Class.forName
-	    throw new JavaException(this, 1, e);
-	} catch (NoSuchFieldException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (SecurityException e) {         // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (NullPointerException e) {      // Class.getField(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalAccessException e) {    // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	} catch (IllegalArgumentException e) {  // Field.get(..)
-	    throw new JavaException(this, 2, e);
-	}
-    }
-}
-
-
diff --git a/src/builtin/builtins.pl b/src/builtin/builtins.pl
index 9b4d15a..b0721c6 100644
--- a/src/builtin/builtins.pl
+++ b/src/builtin/builtins.pl
@@ -90,8 +90,6 @@
 	catch('$meta_call'(X, P, Cut, Depth, Mode), Y, '$meta_call'(Z, P, Cut, Depth, Mode)).
 %'$meta_call'(freeze(X,Y), P, Cut, Depth, Mode) :- !, ???
 %	freeze(X, '$meta_call'(Y, P, Cut, Depth, Mode)).
-'$meta_call'(synchronized(X,Y), P, Cut, Depth, Mode) :- !,
-	synchronized(X, '$meta_call'(Y, P, Cut, Depth, Mode)).
 '$meta_call'(clause(X, Y), P, _, _, _) :- !, clause(P:X, Y).
 '$meta_call'(assert(X), P, _, _, _) :- !, assertz(P:X).
 '$meta_call'(assertz(X), P, _, _, _) :- !, assertz(P:X).
@@ -594,7 +592,6 @@
 '$builtin_meta_predicates'(bagof, 3, [?,:,?]).
 '$builtin_meta_predicates'(on_exception, 3, [?,:,:]).
 '$builtin_meta_predicates'(catch, 3, [:,?,:]).
-'$builtin_meta_predicates'(synchronized, 2, [?,:]).
 '$builtin_meta_predicates'(freeze, 2, [?,:]).
 
 % clause --> term (for retract)
@@ -1887,85 +1884,6 @@
   '$get_hash_manager'(HM),
   hash_contains_key(HM, Alias).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Java interoperation
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%:- public java_constructor0/2.            (written in Java)
-%:- public java_declared_constructor0/2.   (written in Java)
-%:- public java_method0/3.                 (written in Java)
-%:- public java_declared_method0/3.        (written in Java)
-%:- public java_get_field0/3.              (written in Java)
-%:- public java_get_declared_field0/3.     (written in Java)
-%:- public java_set_field0/3.              (written in Java)
-%:- public java_set_declared_field0/3.     (written in Java)
-%:- public java_conversion/2.              (written in Java)
-:- public java_constructor/2.
-:- public java_declared_constructor/2.
-:- public java_method/3.
-:- public java_declared_method/3.
-:- public java_get_field/3.
-:- public java_get_declared_field/3.
-:- public java_set_field/3.
-:- public java_set_declared_field/3.
-:- public synchronized/2.
-
-java_constructor(Constr, Instance) :-
-	Constr =.. [F|As],
-	builtin_java_convert_args(As, As1),
-	Constr1 =.. [F|As1],
-	java_constructor0(Constr1, Instance1),
-	Instance = Instance1.
-
-java_declared_constructor(Constr, Instance) :-
-	Constr =.. [F|As],
-	builtin_java_convert_args(As, As1),
-	Constr1 =.. [F|As1],
-	java_declared_constructor0(Constr1, Instance1),
-	Instance = Instance1.
-
-java_method(Class_or_Instance, Method, Value) :- 
-	Method =.. [F|As],
-	builtin_java_convert_args(As, As1),
-	Method1 =.. [F|As1],
-	java_method0(Class_or_Instance, Method1, Value1),
-	java_conversion(Value2, Value1),
-	Value = Value2.
-
-java_declared_method(Class_or_Instance, Method, Value) :-
-	Method =.. [F|As],
-	builtin_java_convert_args(As, As1),
-	Method1 =.. [F|As1],
-	java_declared_method0(Class_or_Instance, Method1, Value1),
-	java_conversion(Value2, Value1),
-	Value = Value2.
-
-java_get_field(Class_or_Instance, Field, Value) :-
-	java_get_field0(Class_or_Instance, Field, Value1),
-	java_conversion(Value2, Value1),
-	Value = Value2.
-
-java_get_declared_field(Class_or_Instance, Field, Value) :-
-	java_get_declared_field0(Class_or_Instance, Field, Value1),
-	java_conversion(Value2, Value1),
-	Value = Value2.
-
-java_set_field(Class_or_Instance, Field, Value) :-
-	java_conversion(Value, Value1),
-	java_set_field0(Class_or_Instance, Field, Value1).
-
-java_set_declared_field(Class_or_Instance, Field, Value) :-
-	java_conversion(Value, Value1),
-	java_set_declared_field0(Class_or_Instance, Field, Value1).
-
-builtin_java_convert_args([], []) :- !.
-builtin_java_convert_args([X|Xs], [Y|Ys]) :-
-	java_conversion(X, Y),
-	builtin_java_convert_args(Xs, Ys).
-
-synchronized(Object, Goal) :- 
-	'$begin_sync'(Object, Ref), 
-	call(Goal), 
-	'$end_sync'(Ref).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Prolog interpreter
@@ -2588,7 +2506,6 @@
 	atom(F),
 	integer(A).
 %'$match_type'(evaluable,    X).
-%'$match_type'('convertible to java',  X).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Utilities
diff --git a/src/builtin/system.pl b/src/builtin/system.pl
index 938ba99..2d80aff 100644
--- a/src/builtin/system.pl
+++ b/src/builtin/system.pl
@@ -229,25 +229,6 @@
 system_predicate(hash_remove(_,_)).
 system_predicate(hash_size(_,_)).
 system_predicate('$get_hash_manager'(_)).
-% Java interoperation
-system_predicate(java_constructor0(_,_)).
-system_predicate(java_constructor(_,_)).
-system_predicate(java_declared_constructor0(_,_)).
-system_predicate(java_declared_constructor(_,_)).
-system_predicate(java_method0(_,_,_)).
-system_predicate(java_method(_,_,_)).
-system_predicate(java_declared_method0(_,_,_)).
-system_predicate(java_declared_method(_,_,_)).
-system_predicate(java_get_field0(_,_,_)).
-system_predicate(java_get_field(_,_,_)).
-system_predicate(java_get_declared_field0(_,_,_)).
-system_predicate(java_get_declared_field(_,_,_)).
-system_predicate(java_set_field0(_,_,_)).
-system_predicate(java_set_field(_,_,_)).
-system_predicate(java_set_declared_field0(_,_,_)).
-system_predicate(java_set_declared_field(_,_,_)).
-system_predicate(synchronized(_,_)).
-system_predicate(java_conversion(_,_)).
 % Prolog interpreter
 system_predicate(cafeteria).
 system_predicate(consult(_)).
diff --git a/src/compiler/pl2am.pl b/src/compiler/pl2am.pl
index 36d3ab2..65ebf0b 100644
--- a/src/compiler/pl2am.pl
+++ b/src/compiler/pl2am.pl
@@ -1524,7 +1524,6 @@
 builtin_meta_predicates(setof, 3, [?,:,?]).
 builtin_meta_predicates(on_exception, 3, [?,:,:]).
 builtin_meta_predicates(catch, 3, [:,?,:]).
-builtin_meta_predicates(synchronized, 2, [?,:]).
 builtin_meta_predicates(freeze, 2, [?,:]).
 
 builtin_local_predicates(assert, 1, [:]).
diff --git a/src/lang/Prolog.java b/src/lang/Prolog.java
index 48cdf76..c939c7e 100644
--- a/src/lang/Prolog.java
+++ b/src/lang/Prolog.java
@@ -152,9 +152,6 @@
     });
 
     public static enum Feature {
-      /** Enable the {@code java_*} predicates, supporting reflection in Prolog. */
-      JAVA_REFLECTION,
-
       /** Access to the local filesystem and console. */
       IO,