From 6d19657aa23a087ae2f5346082016462058d8afd Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Thu, 27 Sep 2018 08:54:27 -0700 Subject: [PATCH] fix for issue #913 --- .../com_jme3_bullet_joints_PhysicsJoint.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_PhysicsJoint.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_PhysicsJoint.cpp index 129865034..b00425e88 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_PhysicsJoint.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_PhysicsJoint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,22 @@ extern "C" { return joint->getAppliedImpulse(); } + /* + * Class: com_jme3_bullet_joints_PhysicsJoint + * Method: finalizeNative + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_PhysicsJoint_finalizeNative + (JNIEnv * env, jobject object, jlong jointId) { + btTypedConstraint* joint = reinterpret_cast (jointId); + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + delete(joint); + } + #ifdef __cplusplus } #endif