+- * Adapted from HiddenClassDefiner +- * of Google Guice. +- *
+- */ +- private void loadTrustedLookup() { +- try { +- Class> unsafeType = Class.forName("sun.misc.Unsafe"); +- Field theUnsafeField = unsafeType.getDeclaredField("theUnsafe"); +- theUnsafeField.setAccessible(true); +- Object unsafeInstance = theUnsafeField.get(null); +- Field trustedLookupField = Lookup.class.getDeclaredField("IMPL_LOOKUP"); +- Method baseMethod = unsafeType.getMethod("staticFieldBase", Field.class); +- Object trustedLookupBase = baseMethod.invoke(unsafeInstance, trustedLookupField); +- Method offsetMethod = unsafeType.getMethod("staticFieldOffset", Field.class); +- Object trustedLookupOffset = offsetMethod.invoke(unsafeInstance, trustedLookupField); +- Method getObjectMethod = unsafeType.getMethod("getObject", Object.class, long.class); +- this.trustedLookup = +- (Lookup) getObjectMethod.invoke(unsafeInstance, trustedLookupBase, trustedLookupOffset); +- } catch (Exception e) { +- // Unsafe and trusted lookup is not available +- } +- } +- +- /** +- * Determines a {@link Lookup} instance for the given hostClass. +- *+- * The method first tries to use a static method of the hostClass with the +- * following signature: +- *
+- *
+- *
+- * public static {@link Lookup} lookup();
+- *
+- *
+- * If this fails then it tries to use a trusted lookup +- * instance created via sun.misc.Unsafe. +- *
+- * +- * @param hostClass The target class of the lookup instance +- * @return a lookup instance ornull
if not found
+- */
+- Lookup lookupFor(Class> hostClass) {
+- Lookup lookup = lookups.get(hostClass);
+- if (lookup == null) {
+- try {
+- // try to find a lookup() method first
+- Method lookupMethod = hostClass.getMethod("lookup");
+- lookup = (Lookup) lookupMethod.invoke(null);
+- } catch (Exception e) {
+- // failed to use lookup() method
+- }
+-
+- if (lookup == null && trustedLookup != null) {
+- // use trusted lookup instance if available
+- lookup = trustedLookup.in(hostClass);
+- }
+-
+- if (lookup != null) {
+- lookups.put(hostClass, lookup);
+- }
+- }
+- return lookup;
+- }
+-}
+\ No newline at end of file
+--- parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/ParserTransformer.java 2023-10-11 09:54:38.758788500 +0200
++++ parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/ParserTransformer.java 2023-10-11 09:55:09.205648662 +0200
+@@ -32,8 +32,8 @@
+ public static synchronized