コード例 #1
0
def makeBlob(value):
    f = open("test273p/com/Blob.java", "w")
    f.write(src % value);
    f.close();

    support.compileJava(r"test273p/com/Blob.java")
    support.compileJava(r"test273p/com/BlobWriter.java", classpath="test273p")
コード例 #2
0
def mkjar():
    jarfile = File(jardir, jarfn)
    # create a .jar file containing a .class file
    if not jarfile.exists():
        support.compileJava("%s/%s/%s.java" % (jardir, package, clazz))
        jarPacker = support.JarPacker(jarfile, bufsize=128)
        jarPacker.addFile(clazzfile, parentDirName=package)
        jarPacker.close()
    return jardir + '/' + jarfn, package, clazz
コード例 #3
0
ファイル: jarmaker.py プロジェクト: Britefury/jython
def mkjar():
    jarfile = File(jardir, jarfn)    
    # create a .jar file containing a .class file
    if not jarfile.exists():
        support.compileJava("%s/%s/%s.java" % (jardir, package, clazz))
        jarPacker = support.JarPacker(jarfile, bufsize=128)
        jarPacker.addFile(clazzfile, parentDirName=package)
        jarPacker.close()
    return jardir + '/' + jarfn, package, clazz
コード例 #4
0
def mkspam(a):
    f = open("test081j.java", "w")
    f.write("""
public class test081j {
    public static String spam() { return "%s"; }
    public static void %s() {}
}
""" % (a, a))
    f.close()
    support.compileJava("test081j.java")
コード例 #5
0
ファイル: test081.py プロジェクト: certik/jython
def mkspam(a):
    f = open("test081j.java", "w")
    f.write("""
public class test081j {
    public static String spam() { return "%s"; }
    public static void %s() {}
}
""" % (a, a))
    f.close()
    support.compileJava("test081j.java")
コード例 #6
0
ファイル: test398.py プロジェクト: Britefury/jython
def mkjavaclass():
  mkdir(PACKAGE)
  f = open("%s/%s.java" % (PACKAGE, GOOD_CLAZZ), "w")
  f.write("""
package %s;
public class %s {
}
""" % (PACKAGE, GOOD_CLAZZ))
  f.close()
  support.compileJava("%s/%s.java" % (PACKAGE, GOOD_CLAZZ))
コード例 #7
0
ファイル: test398.py プロジェクト: Anemone95/jython3
def mkjavaclass():
    mkdir(PACKAGE)
    f = open("%s/%s.java" % (PACKAGE, GOOD_CLAZZ), "w")
    f.write("""
package %s;
public class %s {
}
""" % (PACKAGE, GOOD_CLAZZ))
    f.close()
    support.compileJava("%s/%s.java" % (PACKAGE, GOOD_CLAZZ))
コード例 #8
0
import support

support.compileJava("test247j.java")

import java

try:
    import test247j
except java.lang.ExceptionInInitializerError:
    pass
else:
    raise support.TestWarning, "Should raise an ExceptionInInitializerError"

#print dir(test247j)
#t = test247j()
コード例 #9
0
ファイル: test129.py プロジェクト: certik/jython
"""

"""

import support
import java, jarray

support.compileJava("test129j.java")

arr = jarray.zeros(10, java.lang.Class.forName('[I'))
for x in range(10): arr[x] = jarray.zeros(10, 'i')
 
import test129j

test129j.chk(arr)

if arr[0][0] != 47:
    raise support.TestError("Array[0][0] should be 47: %d" % arr[0][0])
コード例 #10
0
ファイル: test294.py プロジェクト: certik/jython
"""
[ #416871 ] proxy fails to have all needed methods
"""

import support

support.compileJava('test294j.java')

import test294j


class PyTestA(test294j):
	def __init__(self):
		output.append( "inited")
	def doStart(self):
		output.append( "started")
	def doEnd(self):
		output.append( "completed")
	def finalize(self):
		pass
	def clone(self):
		return self.__class__()

class PyTestB(test294j):
	def __init__(self):
		output.append( "inited")
	def doStart(self):
		output.append( "started")
	def doEnd(self):
		output.append( "completed")
コード例 #11
0
"""

"""

import support

support.compileJava("test157j.java")

import test157j

from jarray import *
f = zeros(2, 'd')
support.compare(test157j.test(f), "double")
if f[0] == 0:
    raise support.TestError("array not changed")

f = zeros(2, 'f')
support.compare(test157j.test(f), "float")
if f[0] == 0:
    raise support.TestError("array not changed")
コード例 #12
0
"""

"""

import support

support.compileJava("classes/test205j2.java")

import test205j1
support.compare(test205j1.classID, "2051")

import test205j2

support.compare(test205j2.classID, "2052")

support.compare(test205j1.classID, "2051")

support.compare(test205j1().classID, "20510")
support.compare(test205j2().classID, "20520")
support.compare(test205j1().classID, "20510")
コード例 #13
0
"""

"""

import support

support.compileJava("classes/test206j1.java")

import java

#import test206j0
import test206j1

x = test206j1()
support.compare(x.getInt2(), "4")
support.compare(x.getInt(), "3")

コード例 #14
0
import support

support.compileJava("test284j2.java", classpath=".")

import test284j1

assert test284j1().foo() == 'test284j1.foo'

import test284j2

assert test284j2().foo() == 'test284j2.foo'
コード例 #15
0
"""
[ 610576 ] Impl of abstract method not found
"""

import support

support.compileJava("test366i.java")
support.compileJava("test366j.java")

import test366i, test366j


class MyCls(test366j, test366i):
    def __init__(self):
        self.foo()


MyCls()
コード例 #16
0
import support

support.compileJava("test270p/test270j2.java", classpath=".")

from test270p import *
test270j2.printX(test270j1())

from java import net, lang
clu = net.URL(r'file:%s/' % lang.System.getProperty("user.dir"))
ld1 = net.URLClassLoader([clu])
X = ld1.loadClass("test270p.test270j1")
Y = ld1.loadClass("test270p.test270j2")
Y.printX(X())

#import org
#org.python.core.PyJavaClass.dumpDebug()
コード例 #17
0
"""

"""

import support

support.compileJava("classes/test182j.java")

support.compileJPythonc("test182c.py", core=1, jar="test182c.jar", output="test182.err")
support.runJava("test182c", classpath="test182c.jar")

#raise support.TestError("" + `x`)
コード例 #18
0
"""
[ #480390 ] main() does not throw exceptions
"""

import support

support.compileJPythonc("test340c.py",
                        core=1,
                        jar="test340.jar",
                        output="test340.err")
support.compileJava("test340j.java")

rc = support.runJava("test340j", classpath=".", expectError=1)
if rc != 42:
    support.TestError("Did not catch exception correctly %d" % rc)
コード例 #19
0
ファイル: test241.py プロジェクト: shyamalschandra/jython-1
import support

support.compileJava("test241p/test241i.java")

import test241p
class A(test241p.test241i):
   def foo(self, i):
      return i

a = A()
v = a.foo(44)

if v != 44:
   raise support.TestError, "Wrong return value %d" % v
コード例 #20
0
"""
Bug #222847 - Can't access public member of package private base class
"""

import support

support.compileJava("classes/test232p/Foo.java")

from test232p import Foo
try:
    Foo().hi()
except IllegalAccessException:
    raise support.TestError(
        'Should be able to call public method on package protected superclass')
コード例 #21
0
"""
Test class identity for inner classes
[ #452947 ] Class of innerclass inst <> innerclas
"""

import support

support.compileJava('test319j.java')

import test319j

id1 = id(test319j.inner)
id2 = id(test319j.mkinner().__class__)

if id1 != id2:
    print "innerclass different", test319j.inner, test319j.mkinner().__class__
    raise support.TestWarning("innerclass different %s %s" %
                              (test319j.inner, test319j.mkinner().__class__))
コード例 #22
0
ファイル: test338.py プロジェクト: Britefury/jython
"""
[ #480017 ] Proxy supers are loaded from syspath
Running test338j will throw a ClassCastException if a proxy's superclass is loaded
by the syspath classloader.
"""

import support

support.compileJava("test338cl.java", classpath=".")
support.compileJava("test338j1.java", classpath=".")
support.compileJava("test338j.java", classpath=".")

support.runJava("test338j", classpath=".")

コード例 #23
0
"""
Coercion of Integer and Number.
"""

import support

support.compileJava("test091j.java")

import test091j

r = test091j.takeInt(12)
support.compare(r, "takeInt")

r = test091j.takeInteger(12)
support.compare(r, "takeInteger")

r = test091j.takeNumber(12)
support.compare(r, "takeNumber")
コード例 #24
0
"""
Check nonpublic constructor.
"""

import support

support.compileJava("classes/test121p/test121j.java")

from test121p import test121j

try:
    test121j()
except TypeError, e:
    support.compare(e, "no public constructor")
else:
    raise support.TestError("Should fail (access)")
コード例 #25
0
ファイル: test236.py プロジェクト: Britefury/jython
import support, os

support.compileJava("classes/test236j1.java", force=1)
os.remove("classes/test236j2.class")

onimport = 1

import java
try:
   import test236j1
   onimport = 0
   test236j1()
except ImportError:
   raise support.TestError, "Should not raise a simple ImportError"
except java.lang.NoClassDefFoundError:
   if not onimport:
      raise support.TestWarning, "import itself does not imply class initialization"   
else:
   raise support.TestError, "Should raise some exception"



コード例 #26
0
ファイル: test366.py プロジェクト: certik/jython
"""
[ 610576 ] Impl of abstract method not found
"""

import support

support.compileJava("test366i.java");
support.compileJava("test366j.java");

import test366i, test366j

class MyCls(test366j, test366i):
    def __init__(self):
        self.foo();

MyCls()

コード例 #27
0
ファイル: test204.py プロジェクト: certik/jython
"""

"""

import support

support.compileJava("classes/test204j2.java")
support.compileJava("classes/test204j3.java")


import test204j1

support.compare(test204j1.classID, "2041")

import test204j2

support.compare(test204j2.classID, "2042")

import test204j3

support.compare(test204j3.classID, "2043")

support.compare(test204j1.classID, "2041")
コード例 #28
0
"""

"""

import support

support.compileJava("classes/test139j2.java")
support.compileJava("classes/test139j3.java")

import test139j1, test139j2


class myclass(test139j1, test139j2):
    def fooMethod(self):
        pass


import test139j3

if not test139j3.baz(myclass()):
    raise support.TestError("myclass should implement test139j2")
コード例 #29
0
"""
[ #451552 ] case insensitivity on import causes prob
"""

import support
import java

support.compileJava("classes/test336p/Data.java")
support.compileJava("classes/test336p/data/MyData.java")

from test336p.data import MyData
コード例 #30
0
ファイル: test244.py プロジェクト: Britefury/jython
import support

support.compileJava("test244p/A.java")

import test244p.A

a=test244p.A()
コード例 #31
0
'''
Confirms the correct bevahior of Python int to Java byte coercion.  Even though
a Python int can be expressed in a byte like format such as 0xFF, Java bytes
only range from -128 to 127 so any int greater than 0x80 should throw a
TypeError if it's passed to something expecting a Java byte.  
'''
import support

support.compileJava("classes/test399j.java")

import test399j

test399j.takesByteArray([0x7E, 0x12])
try:
    test399j.takesByteArray([0xFF, 0x00])
    raise support.TestError('0xFF should not be acceptable as a Java byte')
except TypeError:
    pass#expected since 0xFF can't be coerced to a Java byte
コード例 #32
0
import support

support.compileJava("test250j.java")

import test250j

t = test250j()
v = t[3]
if v != 6:
    raise support.TestError, "wrong return value %d" % v

try:
    print t.a
except AttributeError:
    # Do not support __getattr__ on java classes. (for now at least)
    pass
コード例 #33
0
import support, os

support.compileJava("classes/test236j1.java", force=1)
os.remove("classes/test236j2.class")

onimport = 1

import java
try:
    import test236j1
    onimport = 0
    test236j1()
except ImportError:
    raise support.TestError, "Should not raise a simple ImportError"
except java.lang.NoClassDefFoundError:
    if not onimport:
        raise support.TestWarning, "import itself does not imply class initialization"
else:
    raise support.TestError, "Should raise some exception"
コード例 #34
0
ファイル: test092.py プロジェクト: certik/jython
def mkj1(v):
    f = open("classes/test092m/test092j1.java", "w")
    f.write(j1file % v)
    f.close()
    support.compileJava("classes/test092m/test092j1.java")
コード例 #35
0
ファイル: test091.py プロジェクト: certik/jython
"""
Coercion of Integer and Number.
"""

import support

support.compileJava("test091j.java")

import test091j 

r = test091j.takeInt(12) 
support.compare(r, "takeInt")

r = test091j.takeInteger(12) 
support.compare(r, "takeInteger")

r = test091j.takeNumber(12)
support.compare(r, "takeNumber")
コード例 #36
0
ファイル: test364.py プロジェクト: Britefury/jython
"""
[ 531256 ] Constructor problem using newInstance()
"""

import support

support.compileJava("test364p/X.java")
support.compileJava("test364p/Y.java")

from test364p import X,Y
class PyX(X): pass
class PyY(Y): pass
PyX.useClass(PyY)
X() # OK
try:
    PyX() # Not OK prints 'TypeError: Proxy instance reused'
except TypeError:
    raise support.TestWarning('Class ctor should mix with newInstance()')
コード例 #37
0
"""

"""

import support

support.compileJava("test278p/bug.java", classpath=".")

from test278p import bug
b = bug()
assert b.getName() == "name"
assert b.name == "name"

#raise support.TestError("" + `x`)
コード例 #38
0
ファイル: test277.py プロジェクト: certik/jython
"""

"""

import support

support.compileJava("test277p/Test.java")

from test277p import Test

cnt = 0


class pytest(Test):
    def initialize(self):
        global cnt
        Test.initialize(self)
        cnt += 1


pt = pytest()

support.compare(cnt, "2")

cnt = 0

import java

pt = java.lang.Class.newInstance(pytest)

support.compare(cnt, "2")
コード例 #39
0
ファイル: test219.py プロジェクト: certik/jython
import support

support.compileJava("classes/test219j.java")

import test219i, test219e, test219j

class test219(test219i):
    def foo(self):
         raise test219e("raised in foo()")
    def foo2(self, i):
         if i == 0:
             raise test219e("test219e raised in foo()")
         else:
             raise java.lang.Throwable("Throwable raised in foo()")


a = test219()

test219j.checkFoo(a)
test219j.checkFoo2(a, 0)
test219j.checkFoo2(a, 1)
コード例 #40
0
"""
Test proxy maker from sys.path. CLASSPATH must *not* include "." in this test.
"""

import support

support.compileJava("test083j1.java")

import test083j1


class A(test083j1):
    pass
コード例 #41
0
ファイル: test092.py プロジェクト: certik/jython
def mkj2(v):
    f = open("classes/test092m/test092j2.java", "w")
    f.write(j2file % v);
    f.close();
    support.compileJava("classes/test092m/test092j2.java")
コード例 #42
0
"""
Calling static methods in subclass.
"""

import support

support.compileJava("classes/test084j3.java")

import test084j3

r = test084j3.main(["xxx"])
support.compare(r, "test084j3")

r = test084j3.ohMy()
support.compare(r, "test084j3")
コード例 #43
0
"""

"""

import support

support.compileJava("classes/test288j.java")

import test288j, test288i


class t:
    def __init__(self, s):
        self.s = s

    def __getattr__(self, name):
        return getattr(self.s, name)


class u(test288i):
    def __init__(self, s):
        self.s = s

    def get(self, i=None):
        if i:
            return self.s.get(i)
        else:
            return self.s.get()


class v(test288i):
コード例 #44
0
"""
BigDecimal return coerced into integer
"""

import support

support.compileJava("test066j.java")

import java
import test066j
x = java.math.BigDecimal("123.4321")
y = test066j.asBigDecimal()

if type(x) != type(y):
    raise support.TestError("BigDecimal coerced")

if x != y:
    raise support.TestError("BigDecimal coerced")




コード例 #45
0
"""

"""

import support

support.compileJava("classes/test160j1.java")

import test160j1
a = test160j1()
a.go()

#raise support.TestError("" + `x`)
コード例 #46
0
def mkJavaClass():
    support.compileJava("%s/%s.java" % (TESTDIR, CLAZZ))
コード例 #47
0
ファイル: test232.py プロジェクト: certik/jython
"""
Bug #222847 - Can't access public member of package private base class
"""

import support

support.compileJava("classes/test232p/Foo.java")

from test232p import Foo

try:
    Foo().hi()
except IllegalAccessException:
    raise support.TestError("Should be able to call public method on package protected superclass")
コード例 #48
0
ファイル: test157.py プロジェクト: certik/jython
"""

"""

import support

support.compileJava("test157j.java")

import test157j

from jarray import *
f = zeros(2,'d');
support.compare(test157j.test(f), "double"); 
if f[0] == 0:
    raise support.TestError("array not changed")


f = zeros(2,'f'); 
support.compare(test157j.test(f), "float"); 
if f[0] == 0:
    raise support.TestError("array not changed")

コード例 #49
0
ファイル: test172.py プロジェクト: certik/jython

import support

support.compileJava("test172j.java")

import test172j

support.compare(test172j.foo(1,2,3,4), "foo called with 4 arguments")

support.compare(test172j().bar(1,2,3,4), "bar called with 4 arguments")
コード例 #50
0
ファイル: test394.py プロジェクト: Britefury/jython
def mkJavaClass():
  support.compileJava("%s/%s.java" % (TESTDIR, CLAZZ))