Skip to content
Draft
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8cf243a
moved tests to subpkg jpype.test (1)
marscher Apr 5, 2025
a733880
fix package names in java files
marscher Apr 5, 2025
713ed2b
f array
marscher Apr 5, 2025
c90f7e3
f reflect
marscher Apr 5, 2025
fe1ae88
f zzz
marscher Apr 5, 2025
0fa1fad
f virt
marscher Apr 5, 2025
2aab970
f functional
marscher Apr 5, 2025
d0b353a
f ref
marscher Apr 5, 2025
208a490
f proxy
marscher Apr 5, 2025
15cd159
f directbuff
marscher Apr 5, 2025
81f9d29
f legacy
marscher Apr 5, 2025
0d6f7aa
f attr
marscher Apr 5, 2025
d15eeef
f exc
marscher Apr 5, 2025
56734f0
f forname
marscher Apr 5, 2025
8199a29
f char
marscher Apr 5, 2025
b689c92
f primitives
marscher Apr 5, 2025
63f4342
f stuff
marscher Apr 5, 2025
a7e0891
f stuff
marscher Apr 5, 2025
6b4a38d
f stuff
marscher Apr 5, 2025
bbd6ee7
f imports
marscher Apr 5, 2025
b710142
f javacoverage
marscher Apr 5, 2025
30ff565
f files
marscher Apr 5, 2025
201c6e8
[refactor out] Since we are relying on pytest for a long time now. We…
marscher Apr 5, 2025
bbfa677
f javadoc
marscher Apr 5, 2025
3158ab8
f classhints
marscher Apr 5, 2025
ba5d336
f imports
marscher Apr 5, 2025
34b1e17
f customizer
marscher Apr 5, 2025
00dd676
f collection
marscher Apr 5, 2025
e8c8f19
f fff
marscher Apr 5, 2025
6884dbd
f boxed
marscher Apr 5, 2025
104ee33
f caller sensitive
marscher Apr 5, 2025
d7eef44
[refactor] made start_test_jvm a global function
marscher Apr 5, 2025
837cbde
fix subrun
marscher Apr 5, 2025
4803645
fix properties
marscher Apr 5, 2025
fb02829
fix conversion
marscher Apr 5, 2025
e47a49d
fix varargs
marscher Apr 5, 2025
e2e6178
fix numeric, objwrapper
marscher Apr 5, 2025
cb34f24
fix legacy
marscher Apr 5, 2025
e064dbc
fix utf8
marscher Apr 5, 2025
4fc50c5
minor
marscher Apr 5, 2025
ae3abab
f overloads
marscher Apr 5, 2025
1c43f94
f serial
marscher Apr 5, 2025
a737464
store custom options for later access
marscher Apr 5, 2025
083c68b
f coverage
marscher Apr 5, 2025
a4e9ff3
f proxy multithreaded
marscher Apr 5, 2025
fe05d92
cleanup
marscher Apr 5, 2025
4ce1a22
f startup (wip)
marscher Apr 5, 2025
aa4ef97
merged master (squashed)
marscher Apr 5, 2025
d468557
fix path
marscher Apr 5, 2025
4959f85
[pyproject.toml] fix license value (table is deprecated in setuptools)
marscher Apr 5, 2025
998e5dc
fix mypy issue
marscher Apr 6, 2025
06670a4
fix startup
marscher Apr 6, 2025
5f16998
cleanup
marscher Apr 6, 2025
fbd0dce
finally moved all harness classes to "org.jpype.test" Java package.
marscher Apr 6, 2025
aa6b6e0
fix
marscher Apr 6, 2025
812f95d
use Ant to build testing jars (wip)
marscher Apr 6, 2025
d5a7478
use Ant to build testing jars (wip)
marscher Apr 6, 2025
12d6ac2
[pyproject.toml] fix license
marscher Apr 16, 2025
3332693
replaced self.assertTrue with assert
marscher Apr 16, 2025
2c7d41a
fix path
marscher Apr 16, 2025
37480cb
minor
marscher Apr 16, 2025
80072bc
Merge branch 'master' into testing_updates
marscher Jul 7, 2025
95d3fc1
Merge branch 'master' into testing_updates
marscher Sep 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.5.2.dev0
current_version = 1.6.0.dev0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
8 changes: 7 additions & 1 deletion doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ Changelog
This changelog *only* contains changes from the *first* pypi release (0.5.4.3) onwards.

Latest Changes:
- **1.5.2.dev0 - 2024-11-18**
- **1.6.0.dev0 - 2025-01-20**

- JArray is now registered as a Sequence.

- Fixed bugs with java.util.List concat and repeat methods.

- **1.5.2 - 2025-01-20**

- Roll back agent change due to misbehaving JVM installs.

Expand Down
2 changes: 1 addition & 1 deletion jpype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
__all__.extend(_jcustomizer.__all__) # type: ignore[name-defined]
__all__.extend(_gui.__all__) # type: ignore[name-defined]

__version__ = "1.5.2.dev0"
__version__ = "1.6.0.dev0"
__version_info__ = __version__.split('.')


Expand Down
6 changes: 3 additions & 3 deletions jpype/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,17 @@ def synchronized(obj):
return _jpype._JMonitor(obj)


def getJVMVersion():
def getJVMVersion() -> tuple[int, int, int]:
""" Get the JVM version if the JVM is started.

This function can be used to determine the version of the JVM. It is
useful to help determine why a Jar has failed to load.

Returns:
A typle with the (major, minor, revison) of the JVM if running.
A tuple with the (major, minor, revision) of the JVM if running.
"""
if not _jpype.isStarted():
return (0, 0, 0)
return 0, 0, 0

import re
runtime = _jpype.JClass('java.lang.Runtime')
Expand Down
2 changes: 2 additions & 0 deletions jpype/_jarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# *****************************************************************************
import _jpype
from . import _jcustomizer
from collections.abc import Sequence


__all__ = ['JArray']
Expand Down Expand Up @@ -216,3 +217,4 @@ def __eq__(self, other):
# Install module hooks
_jcustomizer._applyCustomizerPost(_jpype._JArray, _JArrayProto)
_jpype.JArray = JArray
Sequence.register(_jpype._JArray)
8 changes: 7 additions & 1 deletion jpype/_jcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,16 @@ def __iadd__(self, obj):
return self

def __add__(self, obj):
new = self.clone()
new = _jpype.JClass("java.util.ArrayList")(self)
new.extend(obj)
return new

def __mul__(self, obj):
new = _jpype.JClass("java.util.ArrayList")()
for i in range(obj):
new.extend(self)
return new

@JOverride(sticky=True, rename='remove_')
def remove(self, obj):
try:
Expand Down
2 changes: 1 addition & 1 deletion jpype/_jvmfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def find_libjvm(self, java_home):
found_non_supported_jvm = False

# Look for the file
for root, _, names in os.walk(java_home):
for root, _, names in sorted(os.walk(java_home), key=lambda t: len(t[0].split(os.sep))):
if self._libfile in names:
# Found it, but check for non supported jvms
candidate = os.path.split(root)[1]
Expand Down
44 changes: 31 additions & 13 deletions native/common/jp_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,52 @@ void JPContext::startJVM(const string& vmPath, const StringVector& args,
throw;
}

// Determine the memory requirements
#define PAD(x) ((x+31)&~31)
size_t mem = PAD(sizeof(JavaVMInitArgs));
size_t oblock = mem;
mem += PAD(sizeof(JavaVMOption)*args.size() + 1);
size_t sblock = mem;
for (size_t i = 0; i < args.size(); i++)
{
mem += PAD(args[i].size()+1);
}

// Pack the arguments
JP_TRACE("Pack arguments");
JavaVMInitArgs jniArgs;
jniArgs.options = nullptr;
char *block = (char*) malloc(mem);
JavaVMInitArgs* jniArgs = (JavaVMInitArgs*) block;
memset(jniArgs, 0, mem);
jniArgs->options = (JavaVMOption*)(&block[oblock]);

// prepare this ...
jniArgs.version = USE_JNI_VERSION;
jniArgs.ignoreUnrecognized = ignoreUnrecognized;
jniArgs->version = USE_JNI_VERSION;
jniArgs->ignoreUnrecognized = ignoreUnrecognized;
JP_TRACE("IgnoreUnrecognized", ignoreUnrecognized);

jniArgs.nOptions = (jint) args.size();
JP_TRACE("NumOptions", jniArgs.nOptions);
jniArgs.options = new JavaVMOption[jniArgs.nOptions];
memset(jniArgs.options, 0, sizeof (JavaVMOption) * jniArgs.nOptions);
for (int i = 0; i < jniArgs.nOptions; i++)
jniArgs->nOptions = (jint) args.size();
JP_TRACE("NumOptions", jniArgs->nOptions);
size_t j = sblock;
for (size_t i = 0; i < args.size(); i++)
{
JP_TRACE("Option", args[i]);
jniArgs.options[i].optionString = (char*) args[i].c_str();
strncpy(&block[j], args[i].c_str(), args[i].size());
jniArgs->options[i].optionString = (char*) &block[j];
j += PAD(args[i].size()+1);
}

// Launch the JVM
JNIEnv* env = nullptr;
JP_TRACE("Create JVM");
try
{
CreateJVM_Method(&m_JavaVM, (void**) &env, (void*) &jniArgs);
CreateJVM_Method(&m_JavaVM, (void**) &env, (void*) jniArgs);
} catch (...)
{
JP_TRACE("Exception in CreateJVM?");
}
JP_TRACE("JVM created");
delete [] jniArgs.options;
free(jniArgs);

if (m_JavaVM == nullptr)
{
Expand Down Expand Up @@ -489,10 +503,14 @@ extern "C" JNIEXPORT void JNICALL Java_org_jpype_JPypeContext_onShutdown

static int interruptState = 0;
extern "C" JNIEXPORT void JNICALL Java_org_jpype_JPypeSignal_interruptPy
(JNIEnv *env, jclass cls)
(JNIEnv *env, jclass cls, jint signal)
{
interruptState = 1;
#if PY_MINOR_VERSION<10
PyErr_SetInterrupt();
#else
PyErr_SetInterruptEx((int) signal);
#endif
}

extern "C" JNIEXPORT void JNICALL Java_org_jpype_JPypeSignal_acknowledgePy
Expand Down
2 changes: 1 addition & 1 deletion native/java/org/jpype/JPypeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
public class JPypeContext
{

public final String VERSION = "1.5.2.dev0";
public final String VERSION = "1.6.0.dev0";

private static final JPypeContext INSTANCE = new JPypeContext();
// This is the C++ portion of the context.
Expand Down
33 changes: 16 additions & 17 deletions native/java/org/jpype/JPypeSignal.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
**************************************************************************** */
package org.jpype;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
Expand All @@ -31,6 +30,17 @@ public class JPypeSignal

static Thread main;

static Object getSignalHandler(Class signalHandlerClazz, int signal) throws ClassNotFoundException {
return Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]
{
signalHandlerClazz
}, (proxy, method, args) -> {
main.interrupt();
interruptPy(signal);
return null;
});
}

static void installHandlers()
{
try
Expand All @@ -39,28 +49,17 @@ static void installHandlers()
Class SignalHandler = Class.forName("sun.misc.SignalHandler");
main = Thread.currentThread();
Method method = Signal.getMethod("handle", Signal, SignalHandler);

Object handler = Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]
{
SignalHandler
}, new InvocationHandler()
{
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
main.interrupt();
interruptPy();
return null;
}
});
Object intr = Signal.getDeclaredConstructor(String.class).newInstance("INT");
method.invoke(null, intr, handler);
method.invoke(null, intr, getSignalHandler(SignalHandler, 2));
Object intrTerm = Signal.getDeclaredConstructor(String.class).newInstance("TERM");
method.invoke(null, intrTerm, getSignalHandler(SignalHandler, 15));
} catch (InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | ClassNotFoundException | NoSuchMethodException | SecurityException ex)
{
// If we don't get the signal handler run without it. (ANDROID)
}
}

native static void interruptPy();
native static void interruptPy(int signal);

native static void acknowledgePy();
}
2 changes: 1 addition & 1 deletion native/python/pyjp_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ PyMODINIT_FUNC PyInit__jpype()
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
PyModule_AddStringConstant(module, "__version__", "1.5.2.dev0");
PyModule_AddStringConstant(module, "__version__", "1.6.0.dev0");

// Our module will be used for PyFrame object and it is a requirement that
// we have a builtins in our dictionary.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "jpype1"
version = '1.5.2.dev0'
version = '1.6.0.dev0'
authors = [
{name = "Steve Menard", email = "devilwolf@users.sourceforge.net"},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.lambda;
package jpype.test.lambda;

import java.util.function.Function;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.method;
package jpype.test.method;

import jdk.internal.reflect.CallerSensitive;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.array;
package jpype.test.array;

public class Test2
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.array;
package jpype.test.array;

public class TestArray
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

import java.awt.image.BufferStrategy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class Holder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class SubHolder extends Holder implements java.io.Serializable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class Test1
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class Test2 extends Test1
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class TestKeywords
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class TestOverloadA
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class TestOverloadB extends TestOverloadA
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.attr;
package jpype.test.attr;

public class TestOverloadC extends TestOverloadB
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

See NOTICE file for details.
**************************************************************************** */
package jpype.boxed;
package jpype.test.boxed;

public class Boxed
{
Expand Down
Loading
Loading