Description: updating ConstructorAccessTest.java to fit the changes in class
 loading brought by OpenJDK17. These changes will be in next upstream version.
Author: Pierre Gruet <pgt@debian.org>
Origin: upstream, https://github.com/EsotericSoftware/reflectasm/commit/cad4d755114e80169727fd030c85d55db3997bd8
Bug: https://github.com/EsotericSoftware/reflectasm/issues/89
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012106
Last-Update: 2022-11-11

--- a/test/com/esotericsoftware/reflectasm/ConstructorAccessTest.java
+++ b/test/com/esotericsoftware/reflectasm/ConstructorAccessTest.java
@@ -14,11 +14,21 @@
 
 package com.esotericsoftware.reflectasm;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
+import java.util.List;
+
 import junit.framework.TestCase;
 
 public class ConstructorAccessTest extends TestCase {
+    static private boolean java17;
+	static {
+		try {
+			Object version = Runtime.class.getDeclaredMethod("version").invoke(null);
+			java17 = ((List<Integer>)version.getClass().getDeclaredMethod("version").invoke(version)).get(0) >= 17;
+		} catch (Exception ignored) {
+			java17 = false;
+		}
+	}
+
 	public void testNewInstance () {
 		ConstructorAccess<SomeClass> access = ConstructorAccess.get(SomeClass.class);
 		SomeClass someObject = new SomeClass();
@@ -28,6 +38,7 @@
 	}
 
 	public void testPackagePrivateNewInstance () {
+        if (java17) return;
 		ConstructorAccess<PackagePrivateClass> access = ConstructorAccess.get(PackagePrivateClass.class);
 		PackagePrivateClass someObject = new PackagePrivateClass();
 		assertEquals(someObject, access.newInstance());
@@ -44,7 +55,7 @@
 			System.out.println("Expected exception happened: " + re);
 		}
 		catch (Throwable t) {
-			System.out.println("Unexpected exception happened: " + t);
+            t.printStackTrace();
 			assertTrue(false);
 		}
 	}
@@ -58,31 +69,33 @@
 			System.out.println("Expected exception happened: " + re);
 		}
 		catch (Throwable t) {
-			System.out.println("Unexpected exception happened: " + t);
+            t.printStackTrace();
 			assertTrue(false);
 		}
 	}
 
 	public void testHasProtectedConstructor () {
+        if (java17) return;
 		try {
 			ConstructorAccess<HasProtectedConstructor> access = ConstructorAccess.get(HasProtectedConstructor.class);
 			HasProtectedConstructor newInstance = access.newInstance();
 			assertEquals("cow", newInstance.getMoo());
 		}
 		catch (Throwable t) {
-			System.out.println("Unexpected exception happened: " + t);
+            t.printStackTrace();
 			assertTrue(false);
 		}
 	}
 
-	public void testHasPackageProtectedConstructor () {
+	public void testHasPackagePrivateConstructor () {
+        if (java17) return;
 		try {
-			ConstructorAccess<HasPackageProtectedConstructor> access = ConstructorAccess.get(HasPackageProtectedConstructor.class);
-			HasPackageProtectedConstructor newInstance = access.newInstance();
+			ConstructorAccess<HasPackagePrivateConstructor> access = ConstructorAccess.get(HasPackagePrivateConstructor.class);
+			HasPackagePrivateConstructor newInstance = access.newInstance();
 			assertEquals("cow", newInstance.getMoo());
 		}
 		catch (Throwable t) {
-			System.out.println("Unexpected exception happened: " + t);
+            t.printStackTrace();
 			assertTrue(false);
 		}
 	}
@@ -94,7 +107,7 @@
 			assertEquals("cow", newInstance.getMoo());
 		}
 		catch (Throwable t) {
-			System.out.println("Unexpected exception happened: " + t);
+            t.printStackTrace();
 			assertTrue(false);
 		}
 	}
@@ -189,14 +202,14 @@
 		}
 	}
 
-	static public class HasPackageProtectedConstructor extends HasProtectedConstructor {
-		HasPackageProtectedConstructor () {
+	static public class HasPackagePrivateConstructor extends HasProtectedConstructor {
+		HasPackagePrivateConstructor () {
 			super();
 		}
 	}
 
-	static public class HasPublicConstructor extends HasPackageProtectedConstructor {
-		HasPublicConstructor () {
+	static public class HasPublicConstructor extends HasPackagePrivateConstructor {
+		public HasPublicConstructor () {
 			super();
 		}
 	}
