Skip to content

Commit 2b4a75e

Browse files
committed
glue: check the values returned by JNIEnv::GetMethodID()
1 parent 1c74f7c commit 2b4a75e

16 files changed

+51
-13
lines changed

src/main/native/glue/cu/CustomBodyActivationListener.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -50,9 +50,11 @@ class CustomBodyActivationListener : BodyActivationListener {
5050
EXCEPTION_CHECK(pEnv)
5151

5252
mActivatedMethodId = pEnv->GetMethodID(clss, "onBodyActivated", "(IJ)V");
53+
JPH_ASSERT(NULL != mActivatedMethodId);
5354
EXCEPTION_CHECK(pEnv)
5455

5556
mDeactivatedMethodId = pEnv->GetMethodID(clss, "onBodyDeactivated", "(IJ)V");
57+
JPH_ASSERT(NULL != mDeactivatedMethodId);
5658
EXCEPTION_CHECK(pEnv)
5759
}
5860

src/main/native/glue/cu/CustomCastRayCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCastRayCollector : CastRayCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(J)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomCastShapeBodyCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2025 Stephen Gold
2+
Copyright (c) 2025-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCastShapeBodyCollector : CastShapeBodyCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(J)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomCastShapeCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCastShapeCollector : CastShapeCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(J)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomCharacterContactListener.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -58,46 +58,57 @@ class CustomCharacterContactListener : CharacterContactListener {
5858

5959
mAddedMethodId = pEnv->GetMethodID(
6060
clss, "onContactAdded", "(JIIDDDFFFJ)V");
61+
JPH_ASSERT(NULL != mAddedMethodId);
6162
EXCEPTION_CHECK(pEnv)
6263

6364
mAdjustMethodId = pEnv->GetMethodID(
6465
clss, "onAdjustBodyVelocity", "(JJ[F)V");
66+
JPH_ASSERT(NULL != mAdjustMethodId);
6567
EXCEPTION_CHECK(pEnv)
6668

6769
mCcAddedMethodId = pEnv->GetMethodID(
6870
clss, "onCharacterContactAdded", "(JJIDDDFFFJ)V");
71+
JPH_ASSERT(NULL != mCcAddedMethodId);
6972
EXCEPTION_CHECK(pEnv)
7073

7174
mCcPersistedMethodId = pEnv->GetMethodID(
7275
clss, "onCharacterContactPersisted", "(JJIDDDFFFJ)V");
76+
JPH_ASSERT(NULL != mCcPersistedMethodId);
7377
EXCEPTION_CHECK(pEnv)
7478

7579
mCcRemovedMethodId = pEnv->GetMethodID(
7680
clss, "onCharacterContactRemoved", "(JII)V");
81+
JPH_ASSERT(NULL != mCcRemovedMethodId);
7782
EXCEPTION_CHECK(pEnv)
7883

7984
mCcSolveMethodId = pEnv->GetMethodID(
8085
clss, "onCharacterContactSolve", "(JJIDDDFFFFFFJFFF[F)V");
86+
JPH_ASSERT(NULL != mCcSolveMethodId);
8187
EXCEPTION_CHECK(pEnv)
8288

8389
mCcValidateMethodId = pEnv->GetMethodID(
8490
clss, "onCharacterContactValidate", "(JJI)Z");
91+
JPH_ASSERT(NULL != mCcValidateMethodId);
8592
EXCEPTION_CHECK(pEnv)
8693

8794
mPersistedMethodId = pEnv->GetMethodID(
8895
clss, "onContactPersisted", "(JIIDDDFFFJ)V");
96+
JPH_ASSERT(NULL != mPersistedMethodId);
8997
EXCEPTION_CHECK(pEnv)
9098

9199
mRemovedMethodId = pEnv->GetMethodID(
92100
clss, "onContactRemoved", "(JII)V");
101+
JPH_ASSERT(NULL != mRemovedMethodId);
93102
EXCEPTION_CHECK(pEnv)
94103

95104
mSolveMethodId = pEnv->GetMethodID(
96105
clss, "onContactSolve", "(JIIDDDFFFFFFJFFF[F)V");
106+
JPH_ASSERT(NULL != mSolveMethodId);
97107
EXCEPTION_CHECK(pEnv)
98108

99109
mValidateMethodId = pEnv->GetMethodID(
100110
clss, "onContactValidate", "(JII)Z");
111+
JPH_ASSERT(NULL != mValidateMethodId);
101112
EXCEPTION_CHECK(pEnv)
102113
}
103114

src/main/native/glue/cu/CustomCollidePointCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCollidePointCollector : CollidePointCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(J)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomCollideShapeBodyCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCollideShapeBodyCollector : CollideShapeBodyCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(I)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomCollideShapeCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -47,6 +47,7 @@ class CustomCollideShapeCollector : CollideShapeCollector {
4747
EXCEPTION_CHECK(pEnv)
4848

4949
mAddMethodId = pEnv->GetMethodID(clss, "addHit", "(J)V");
50+
JPH_ASSERT(NULL != mAddMethodId);
5051
EXCEPTION_CHECK(pEnv)
5152
}
5253

src/main/native/glue/cu/CustomContactListener.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024-2025 Stephen Gold
2+
Copyright (c) 2024-2026 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -50,15 +50,19 @@ class CustomContactListener : ContactListener {
5050
EXCEPTION_CHECK(pEnv)
5151

5252
mAddedMethodId = pEnv->GetMethodID(clss, "onContactAdded", "(JJJJ)V");
53+
JPH_ASSERT(NULL != mAddedMethodId);
5354
EXCEPTION_CHECK(pEnv)
5455

5556
mPersistedMethodId = pEnv->GetMethodID(clss, "onContactPersisted", "(JJJJ)V");
57+
JPH_ASSERT(NULL != mPersistedMethodId);
5658
EXCEPTION_CHECK(pEnv)
5759

5860
mRemovedMethodId = pEnv->GetMethodID(clss, "onContactRemoved", "(J)V");
61+
JPH_ASSERT(NULL != mRemovedMethodId);
5962
EXCEPTION_CHECK(pEnv)
6063

6164
mValidateMethodId = pEnv->GetMethodID(clss, "onContactValidate", "(JJDDDJ)I");
65+
JPH_ASSERT(NULL != mValidateMethodId);
6266
EXCEPTION_CHECK(pEnv)
6367
}
6468

src/main/native/glue/cu/CustomDebugRendererSimple.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ class CustomDebugRendererSimple : public DebugRendererSimple {
5050
EXCEPTION_CHECK(pEnv)
5151

5252
mDrawLineId = pEnv->GetMethodID(clss, "drawLine", "(DDDDDDI)V");
53+
JPH_ASSERT(NULL != mDrawLineId);
5354
EXCEPTION_CHECK(pEnv)
5455

5556
mDrawTextId = pEnv->GetMethodID(
5657
clss, "drawText3d", "(DDDLjava/lang/String;IF)V");
58+
JPH_ASSERT(NULL != mDrawTextId);
5759
EXCEPTION_CHECK(pEnv)
5860

5961
mDrawTriangleId
6062
= pEnv->GetMethodID(clss, "drawTriangle", "(DDDDDDDDDII)V");
63+
JPH_ASSERT(NULL != mDrawTriangleId);
6164
EXCEPTION_CHECK(pEnv)
6265
}
6366

0 commit comments

Comments
 (0)