Accepting request 1116885 from Java:packages
1.4.1 + remove *-scala subpackage not needed by anybody OBS-URL: https://build.opensuse.org/request/show/1116885 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/parboiled?expand=0&rev=6
This commit is contained in:
commit
61930f01dc
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:793fe27f8aa5ae71e6dc09bcda702835ad9a23329d61cd26de046cfdcb0fbe5d
|
||||
size 215393
|
BIN
1.4.1.tar.gz
(Stored with Git LFS)
Normal file
BIN
1.4.1.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
<multibuild>
|
||||
<package>scala</package>
|
||||
</multibuild>
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b4a7d350818ea568dee926ffef3098a2d228f57b16e594b17f04f29b767c0a64
|
||||
size 2796
|
3
parboiled-build.tar.xz
Normal file
3
parboiled-build.tar.xz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1b426cd0ac656fe6c6d19037a13766a8214195517d409c2d2b62beed0f48087a
|
||||
size 2856
|
@ -3,10 +3,10 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.parboiled</groupId>
|
||||
<artifactId>parboiled-core</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<packaging>jar</packaging>
|
||||
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||
<url>http://parboiled.org</url>
|
||||
<version>1.1.6</version>
|
||||
<version>1.4.1</version>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
@ -32,15 +32,15 @@
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.14.1</version>
|
||||
<groupId>org.scalatestplus</groupId>
|
||||
<artifactId>testng-7-5_2.13</artifactId>
|
||||
<version>3.2.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.9.3</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<artifactId>scalatest_2.13</artifactId>
|
||||
<version>3.2.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
@ -3,10 +3,10 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.parboiled</groupId>
|
||||
<artifactId>parboiled-java</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<packaging>jar</packaging>
|
||||
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||
<url>http://parboiled.org</url>
|
||||
<version>1.1.6</version>
|
||||
<version>1.4.1</version>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
@ -34,39 +34,39 @@
|
||||
<dependency>
|
||||
<groupId>org.parboiled</groupId>
|
||||
<artifactId>parboiled-core</artifactId>
|
||||
<version>1.1.6</version>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.14.1</version>
|
||||
<groupId>org.scalatestplus</groupId>
|
||||
<artifactId>testng-7-5_2.13</artifactId>
|
||||
<version>3.2.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.9.3</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<artifactId>scalatest_2.13</artifactId>
|
||||
<version>3.2.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>4.1</version>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<version>4.1</version>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
<version>4.1</version>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>4.1</version>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,54 +0,0 @@
|
||||
From 66129b1155188b4c2b1d3b34641a7118fd99eb51 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Srb <msrb@redhat.com>
|
||||
Date: Thu, 27 Mar 2014 10:59:08 +0100
|
||||
Subject: [PATCH] Port to objectweb-asm 5.0.1
|
||||
|
||||
---
|
||||
.../src/main/java/org/parboiled/transform/ParserClassNode.java | 2 ++
|
||||
parboiled-java/src/main/java/org/parboiled/transform/RuleMethod.java | 3 ++-
|
||||
2 files changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/parboiled-java/src/main/java/org/parboiled/transform/ParserClassNode.java b/parboiled-java/src/main/java/org/parboiled/transform/ParserClassNode.java
|
||||
index 6534f24..3da751b 100644
|
||||
--- a/parboiled-java/src/main/java/org/parboiled/transform/ParserClassNode.java
|
||||
+++ b/parboiled-java/src/main/java/org/parboiled/transform/ParserClassNode.java
|
||||
@@ -26,6 +26,7 @@ import static org.parboiled.common.Preconditions.*;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
+import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -39,6 +40,7 @@ class ParserClassNode extends ClassNode {
|
||||
private Class<?> extendedClass;
|
||||
|
||||
public ParserClassNode(Class<?> parentClass) {
|
||||
+ super(Opcodes.ASM4);
|
||||
this.parentClass = checkArgNotNull(parentClass, "parentClass");
|
||||
parentType = Type.getType(parentClass);
|
||||
}
|
||||
diff --git a/parboiled-java/src/main/java/org/parboiled/transform/RuleMethod.java b/parboiled-java/src/main/java/org/parboiled/transform/RuleMethod.java
|
||||
index c60ef8a..8c023ca 100644
|
||||
--- a/parboiled-java/src/main/java/org/parboiled/transform/RuleMethod.java
|
||||
+++ b/parboiled-java/src/main/java/org/parboiled/transform/RuleMethod.java
|
||||
@@ -31,6 +31,7 @@ import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.LocalVariableNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.analysis.BasicValue;
|
||||
+import org.objectweb.asm.Opcodes;
|
||||
import org.parboiled.BaseParser;
|
||||
import org.parboiled.common.StringUtils;
|
||||
import org.parboiled.support.Var;
|
||||
@@ -71,7 +72,7 @@ class RuleMethod extends MethodNode {
|
||||
|
||||
public RuleMethod(Class<?> ownerClass, int access, String name, String desc, String signature, String[] exceptions,
|
||||
boolean hasExplicitActionOnlyAnno, boolean hasDontLabelAnno, boolean hasSkipActionsInPredicates) {
|
||||
- super(access, name, desc, signature, exceptions);
|
||||
+ super(Opcodes.ASM4, access, name, desc, signature, exceptions);
|
||||
this.ownerClass = ownerClass;
|
||||
parameterCount = Type.getArgumentTypes(desc).length;
|
||||
hasCachedAnnotation = parameterCount == 0;
|
||||
--
|
||||
1.9.0
|
||||
|
@ -1,57 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.parboiled</groupId>
|
||||
<artifactId>parboiled-scala_2.10</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||
<url>http://parboiled.org</url>
|
||||
<version>1.1.6</version>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<name>parboiled-scala</name>
|
||||
<inceptionYear>2009</inceptionYear>
|
||||
<organization>
|
||||
<name>org.parboiled</name>
|
||||
<url>http://parboiled.org</url>
|
||||
</organization>
|
||||
<scm>
|
||||
<url>git@github.com:sirthias/parboiled.git</url>
|
||||
<connection>scm:git:git@github.com:sirthias/parboiled.git</connection>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>sirthias</id>
|
||||
<name>Mathias Doenitz</name>
|
||||
</developer>
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.parboiled</groupId>
|
||||
<artifactId>parboiled-core</artifactId>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>2.10.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.14.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.10</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,3 +1,52 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 11 07:22:30 UTC 2023 - Fridrich Strba <fstrba@suse.com>
|
||||
|
||||
- Do not build the scala subpackage, since it is not needed by any
|
||||
package
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 6 11:26:05 UTC 2023 - Fridrich Strba <fstrba@suse.com>
|
||||
|
||||
- Upgrade to upstream version 1.4.1
|
||||
* Changes of 1.4.1
|
||||
+ Improved support for Java 16+
|
||||
+ Dropped support for Java 8
|
||||
* Changes of 1.4.0
|
||||
+ Support Java 17
|
||||
+ Upgraded to ASM 9.2
|
||||
+ Dropped support for Scala 2.11
|
||||
* Changes of 1.3.1
|
||||
+ Upgraded to ASM 7.1
|
||||
+ Fixed class loader in parser generation
|
||||
+ Added cross-build for Scala 2.13.0
|
||||
+ Dropped support for Scala 2.10
|
||||
* Changes of 1.3.0
|
||||
+ Upgraded to ASM 7.0
|
||||
+ Added Scala 2.13.0-M5 build
|
||||
* Changes of 1.2.0
|
||||
+ Added support for '~~>' and friends in ReductionRules
|
||||
+ Added support for PushRules to chain after ReductionRules
|
||||
+ Upgraded to ASM 6.2.1
|
||||
+ Added Scala 2.13.0-M4 build
|
||||
+ Dropped support for Java 1.5
|
||||
* Changes of 1.1.8
|
||||
+ Cross build for Scala 2.10, 2.11 and 2.12
|
||||
+ Upgrade to ASM 5.2
|
||||
+ Fixed "Utils.findConstructor doesn't match boolean parameter"
|
||||
+ Added method for clearing class cache in AsmUtil
|
||||
* Changes of 1.1.7
|
||||
+ Upgrade to Scala 2.11.4, cross build for Scala 2.9.2, 2.9.3,
|
||||
2.10 and 2.11
|
||||
+ Upgrade to ASM 5.0.3, closed #76
|
||||
+ Make parboiled-java relocatable, closed #80
|
||||
- Added patch:
|
||||
* restore-java8-compatibility.patch
|
||||
+ revert upstream commit making changes incompatible with
|
||||
Java 8
|
||||
- Removed patch:
|
||||
* parboiled-port-to-objectweb-asm-5.0.1.patch
|
||||
+ not needed with this version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Mar 20 15:24:52 UTC 2022 - Fridrich Strba <fstrba@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file
|
||||
# spec file for package parboiled
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -16,58 +16,28 @@
|
||||
#
|
||||
|
||||
|
||||
%global flavor @BUILD_FLAVOR@%{nil}
|
||||
%if "%{flavor}" == "scala"
|
||||
%bcond_without scala
|
||||
%else
|
||||
%bcond_with scala
|
||||
%endif
|
||||
%global scala_short_version 2.10
|
||||
%global base_name parboiled
|
||||
%if %{with scala}
|
||||
Name: %{base_name}-scala
|
||||
Summary: Parboiled for Scala
|
||||
License: Apache-2.0
|
||||
Group: Development/Libraries/Java
|
||||
%else
|
||||
Name: %{base_name}
|
||||
Summary: Java/Scala library providing parsing of input text based on PEGs
|
||||
License: Apache-2.0
|
||||
Group: Development/Libraries/Java
|
||||
%endif
|
||||
Version: 1.1.6
|
||||
Name: parboiled
|
||||
Version: 1.4.1
|
||||
Release: 0
|
||||
Summary: Java library providing parsing of input text based on PEGs
|
||||
License: Apache-2.0
|
||||
Group: Development/Libraries/Java
|
||||
URL: http://parboiled.org/
|
||||
Source0: https://github.com/sirthias/parboiled/archive/%{version}.tar.gz
|
||||
Source1: %{base_name}-%{version}-build.tar.xz
|
||||
Source1: %{name}-build.tar.xz
|
||||
# for build see https://github.com/sirthias/parboiled/wiki/Building-parboiled
|
||||
Source2: http://repo1.maven.org/maven2/org/parboiled/%{base_name}-core/%{version}/%{base_name}-core-%{version}.pom
|
||||
Source3: http://repo1.maven.org/maven2/org/parboiled/%{base_name}-java/%{version}/%{base_name}-java-%{version}.pom
|
||||
Source4: http://repo1.maven.org/maven2/org/parboiled/%{base_name}-scala_%{scala_short_version}/%{version}/%{base_name}-scala_%{scala_short_version}-%{version}.pom
|
||||
Patch0: parboiled-port-to-objectweb-asm-5.0.1.patch
|
||||
Source2: https://repo1.maven.org/maven2/org/parboiled/%{name}-core/%{version}/%{name}-core-%{version}.pom
|
||||
Source3: https://repo1.maven.org/maven2/org/parboiled/%{name}-java/%{version}/%{name}-java-%{version}.pom
|
||||
Patch0: restore-java8-compatibility.patch
|
||||
BuildRequires: ant
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: java-devel >= 1.8
|
||||
BuildRequires: javapackages-local
|
||||
%if %{with scala}
|
||||
BuildRequires: ant-scala >= 2.10.7
|
||||
BuildRequires: parboiled
|
||||
Requires: mvn(org.parboiled:parboiled-core) = %{version}
|
||||
Requires: mvn(org.scala-lang:scala-library)
|
||||
%else
|
||||
BuildRequires: objectweb-asm
|
||||
Requires: mvn(org.ow2.asm:asm)
|
||||
Requires: mvn(org.ow2.asm:asm-analysis)
|
||||
Requires: mvn(org.ow2.asm:asm-tree)
|
||||
Requires: mvn(org.ow2.asm:asm-util)
|
||||
%endif
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
%if %{with scala}
|
||||
An internal Scala DSL for efficiently defining your parser rules.
|
||||
|
||||
%endif
|
||||
parboiled is a mixed Java/Scala library providing parsing of
|
||||
parboiled is a mixed Java library providing parsing of
|
||||
arbitrary input text based on Parsing expression grammars (PEGs).
|
||||
PEGs are an alternative to context free grammars (CFGs) for formally
|
||||
specifying syntax, they make a replacement for regular expressions
|
||||
@ -82,49 +52,32 @@ Group: Documentation/HTML
|
||||
This package contains javadoc for %{name}.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{base_name}-%{version} -a1
|
||||
|
||||
find . -name "*.class" -delete
|
||||
find . -name "*.jar" -delete
|
||||
|
||||
%setup -q -n %{name}-%{version} -a1
|
||||
%patch0 -p1
|
||||
|
||||
cp %{SOURCE2} %{base_name}-core/pom.xml
|
||||
cp %{SOURCE3} %{base_name}-java/pom.xml
|
||||
cp %{SOURCE4} %{base_name}-scala/pom.xml
|
||||
cp %{SOURCE2} %{name}-core/pom.xml
|
||||
cp %{SOURCE3} %{name}-java/pom.xml
|
||||
|
||||
%build
|
||||
mkdir -p lib
|
||||
build-jar-repository -s lib \
|
||||
%if %{with scala}
|
||||
%{base_name}
|
||||
%else
|
||||
objectweb-asm
|
||||
%endif
|
||||
%{ant} \
|
||||
%if %{with scala}
|
||||
-Dscala.libDir=%{_datadir}/scala/lib \
|
||||
-f build-scala.xml \
|
||||
%endif
|
||||
package javadoc
|
||||
|
||||
%install
|
||||
%if %{with scala}
|
||||
%global modules scala
|
||||
%else
|
||||
%global modules core java
|
||||
%endif
|
||||
install -dm 0755 %{buildroot}%{_javadir}/%{base_name}
|
||||
install -dm 0755 %{buildroot}%{_mavenpomdir}/%{base_name}
|
||||
install -dm 0755 %{buildroot}%{_javadir}/%{name}
|
||||
install -dm 0755 %{buildroot}%{_mavenpomdir}/%{name}
|
||||
for i in %{modules}; do
|
||||
# jar
|
||||
install -pm 0644 %{base_name}-${i}/target/%{base_name}-${i}*%{version}.jar %{buildroot}%{_javadir}/%{base_name}/${i}.jar
|
||||
install -pm 0644 %{name}-${i}/target/%{name}-${i}*%{version}.jar %{buildroot}%{_javadir}/%{name}/${i}.jar
|
||||
# pom
|
||||
install -pm 0644 %{base_name}-${i}/pom.xml %{buildroot}%{_mavenpomdir}/%{base_name}/${i}.pom
|
||||
%add_maven_depmap %{base_name}/${i}.pom %{base_name}/${i}.jar
|
||||
%{mvn_install_pom} %{name}-${i}/pom.xml %{buildroot}%{_mavenpomdir}/%{name}/${i}.pom
|
||||
%add_maven_depmap %{name}/${i}.pom %{name}/${i}.jar
|
||||
# javadoc
|
||||
install -dm 0755 %{buildroot}%{_javadocdir}/%{base_name}/${i}
|
||||
cp -pr %{base_name}-${i}/target/site/apidocs/* %{buildroot}%{_javadocdir}/%{base_name}/${i}/
|
||||
install -dm 0755 %{buildroot}%{_javadocdir}/%{name}/${i}
|
||||
cp -pr %{name}-${i}/target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}/${i}/
|
||||
done
|
||||
%fdupes -s %{buildroot}%{_javadocdir}
|
||||
|
||||
@ -134,6 +87,6 @@ done
|
||||
|
||||
%files javadoc
|
||||
%license LICENSE
|
||||
%{_javadocdir}/%{base_name}
|
||||
%{_javadocdir}/%{name}
|
||||
|
||||
%changelog
|
||||
|
268
restore-java8-compatibility.patch
Normal file
268
restore-java8-compatibility.patch
Normal file
@ -0,0 +1,268 @@
|
||||
--- parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/AsmUtils.java 2023-10-11 09:54:38.742121727 +0200
|
||||
+++ parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/AsmUtils.java 2023-10-11 09:54:51.432202375 +0200
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
-import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -47,8 +46,6 @@
|
||||
|
||||
class AsmUtils {
|
||||
|
||||
- private static final LookupFactory lookupFactory = new LookupFactory();
|
||||
-
|
||||
public static ClassReader createClassReader(Class<?> clazz) throws IOException {
|
||||
checkArgNotNull(clazz, "clazz");
|
||||
String classFilename = clazz.getName().replace('.', '/') + ".class";
|
||||
@@ -199,17 +196,22 @@
|
||||
* Otherwise the method returns null.
|
||||
*
|
||||
* @param className the full name of the class to be loaded
|
||||
- * @param parentClass the parent class of the class with the given className
|
||||
+ * @param classLoader the class loader to use
|
||||
* @return the class instance or null
|
||||
*/
|
||||
- public static Class<?> loadClass(String className, Class<?> parentClass) {
|
||||
+ public static Class<?> findLoadedClass(String className, ClassLoader classLoader) {
|
||||
checkArgNotNull(className, "className");
|
||||
- checkArgNotNull(parentClass, "parentClass");
|
||||
+ checkArgNotNull(classLoader, "classLoader");
|
||||
try {
|
||||
+ Class<?> classLoaderBaseClass = Class.forName("java.lang.ClassLoader");
|
||||
+ Method findLoadedClassMethod = classLoaderBaseClass.getDeclaredMethod("findLoadedClass", String.class);
|
||||
+
|
||||
+ // protected method invocation
|
||||
+ findLoadedClassMethod.setAccessible(true);
|
||||
try {
|
||||
- return parentClass.getClassLoader().loadClass(className);
|
||||
- } catch (ClassNotFoundException cnfe) {
|
||||
- return null;
|
||||
+ return (Class<?>) findLoadedClassMethod.invoke(classLoader, className);
|
||||
+ } finally {
|
||||
+ findLoadedClassMethod.setAccessible(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not determine whether class '" + className +
|
||||
@@ -218,30 +220,22 @@
|
||||
}
|
||||
|
||||
/**
|
||||
- * Defines a new class with the given name and bytecode within the package of the given parent class.
|
||||
- * Since package and class identity includes the ClassLoader instance used to load a class we use reflection
|
||||
+ * Loads the class defined with the given name and bytecode using the given class loader.
|
||||
+ * Since package and class idendity includes the ClassLoader instance used to load a class we use reflection
|
||||
* on the given class loader to define generated classes. If we used our own class loader (in order to be able
|
||||
* to access the protected "defineClass" method) we would likely still be able to load generated classes,
|
||||
* however, they would not have access to package-private classes and members of their super classes.
|
||||
*
|
||||
* @param className the full name of the class to be loaded
|
||||
* @param code the bytecode of the class to load
|
||||
- * @param parentClass the parent class of the new class
|
||||
+ * @param classLoader the class loader to use
|
||||
* @return the class instance
|
||||
*/
|
||||
- public static Class<?> defineClass(String className, byte[] code, Class<?> parentClass) {
|
||||
+ public static Class<?> loadClass(String className, byte[] code, ClassLoader classLoader) {
|
||||
checkArgNotNull(className, "className");
|
||||
checkArgNotNull(code, "code");
|
||||
- checkArgNotNull(parentClass, "parentClass");
|
||||
-
|
||||
+ checkArgNotNull(classLoader, "classLoader");
|
||||
try {
|
||||
- if (lookupFactory != null) {
|
||||
- MethodHandles.Lookup lookup = lookupFactory.lookupFor(parentClass);
|
||||
- if (lookup != null) {
|
||||
- return lookup.defineClass(code);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
Class<?> classLoaderBaseClass = Class.forName("java.lang.ClassLoader");
|
||||
Method defineClassMethod = classLoaderBaseClass.getDeclaredMethod("defineClass",
|
||||
String.class, byte[].class, int.class, int.class);
|
||||
@@ -249,7 +243,7 @@
|
||||
// protected method invocation
|
||||
defineClassMethod.setAccessible(true);
|
||||
try {
|
||||
- return (Class<?>) defineClassMethod.invoke(parentClass.getClassLoader(), className, code, 0, code.length);
|
||||
+ return (Class<?>) defineClassMethod.invoke(classLoader, className, code, 0, code.length);
|
||||
} finally {
|
||||
defineClassMethod.setAccessible(false);
|
||||
}
|
||||
--- parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/GroupClassGenerator.java 2023-10-11 09:54:38.758788500 +0200
|
||||
+++ parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/GroupClassGenerator.java 2023-10-11 09:58:14.413389233 +0200
|
||||
@@ -23,7 +23,8 @@
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
-import static org.parboiled.transform.AsmUtils.defineClass;
|
||||
+import static org.parboiled.transform.AsmUtils.findLoadedClass;
|
||||
+import static org.parboiled.transform.AsmUtils.loadClass;
|
||||
|
||||
abstract class GroupClassGenerator implements RuleMethodProcessor {
|
||||
|
||||
@@ -53,15 +54,16 @@
|
||||
private void loadGroupClass(InstructionGroup group) {
|
||||
createGroupClassType(group);
|
||||
String className = group.getGroupClassType().getClassName();
|
||||
+ ClassLoader classLoader = classNode.getParentClass().getClassLoader();
|
||||
|
||||
Class<?> groupClass;
|
||||
synchronized (lock) {
|
||||
- groupClass = AsmUtils.loadClass(className, classNode.getParentClass());
|
||||
+ groupClass = findLoadedClass(className, classLoader);
|
||||
if (groupClass == null || forceCodeBuilding) {
|
||||
byte[] groupClassCode = generateGroupClassCode(group);
|
||||
group.setGroupClassCode(groupClassCode);
|
||||
if (groupClass == null) {
|
||||
- AsmUtils.defineClass(className, groupClassCode, classNode.getParentClass());
|
||||
+ loadClass(className, groupClassCode, classLoader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +73,7 @@
|
||||
String s = classNode.name;
|
||||
int lastSlash = classNode.name.lastIndexOf('/');
|
||||
// do not prepend a slash if class is in the default package (lastSlash == -1)
|
||||
- String groupClassInternalName = (lastSlash >= 0 ? s.substring(0, lastSlash) + '/' : "") + group.getName();
|
||||
+ String groupClassInternalName = (lastSlash >= 0 ? s.substring(0, lastSlash) : s)+ '/' + group.getName();
|
||||
group.setGroupClassType(Type.getObjectType(groupClassInternalName));
|
||||
}
|
||||
|
||||
--- parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/LookupFactory.java 2023-10-11 09:54:38.758788500 +0200
|
||||
+++ parboiled-1.4.1/parboiled-java/src/main/java/org/parboiled/transform/LookupFactory.java 1970-01-01 01:00:00.000000000 +0100
|
||||
@@ -1,105 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2022 parboiled contributors
|
||||
- *
|
||||
- * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
- * you may not use this file except in compliance with the License.
|
||||
- * You may obtain a copy of the License at
|
||||
- *
|
||||
- * http://www.apache.org/licenses/LICENSE-2.0
|
||||
- *
|
||||
- * Unless required by applicable law or agreed to in writing, software
|
||||
- * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
- * See the License for the specific language governing permissions and
|
||||
- * limitations under the License.
|
||||
- */
|
||||
-
|
||||
-package org.parboiled.transform;
|
||||
-
|
||||
-import java.lang.invoke.MethodHandles.Lookup;
|
||||
-import java.lang.reflect.Field;
|
||||
-import java.lang.reflect.Method;
|
||||
-import java.util.WeakHashMap;
|
||||
-
|
||||
-/**
|
||||
- * Helper that can be used to create {@link Lookup} instances for
|
||||
- * specific classes.
|
||||
- */
|
||||
-final class LookupFactory {
|
||||
-
|
||||
- private WeakHashMap<Class<?>, Lookup> lookups = new WeakHashMap<>();
|
||||
- private Lookup trustedLookup;
|
||||
-
|
||||
- LookupFactory() {
|
||||
- loadTrustedLookup();
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * Tries to load a trusted {@link Lookup} instance.
|
||||
- *
|
||||
- * <p>
|
||||
- * Adapted from <a href="https://github.com/google/guice/blob/cf759d44c78e8490e3d54df6a27918e0811bbdf9/core/src/com/google/inject/internal/aop/HiddenClassDefiner.java#L40">HiddenClassDefiner</a>
|
||||
- * of Google Guice.
|
||||
- * </p>
|
||||
- */
|
||||
- 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.
|
||||
- * <p>
|
||||
- * The method first tries to use a static method of the hostClass with the
|
||||
- * following signature:
|
||||
- * </p>
|
||||
- * <p>
|
||||
- * <code>
|
||||
- * public static {@link Lookup} lookup();
|
||||
- * </code>
|
||||
- * </p>
|
||||
- * <p>
|
||||
- * If this fails then it tries to use a trusted lookup
|
||||
- * instance created via sun.misc.Unsafe.
|
||||
- * </p>
|
||||
- *
|
||||
- * @param hostClass The target class of the lookup instance
|
||||
- * @return a lookup instance or <code>null</code> 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 <T> Class<? extends T> transformParser(Class<T> parserClass) throws Exception {
|
||||
checkArgNotNull(parserClass, "parserClass");
|
||||
// first check whether we did not already create and load the extension of the given parser class
|
||||
- Class<?> extendedClass = AsmUtils.loadClass(
|
||||
- getExtendedParserClassName(parserClass.getName()), parserClass
|
||||
+ Class<?> extendedClass = findLoadedClass(
|
||||
+ getExtendedParserClassName(parserClass.getName()), parserClass.getClassLoader()
|
||||
);
|
||||
return (Class<? extends T>)
|
||||
(extendedClass != null ? extendedClass : extendParserClass(parserClass).getExtendedClass());
|
||||
@@ -102,10 +102,10 @@
|
||||
};
|
||||
classNode.accept(classWriter);
|
||||
classNode.setClassCode(classWriter.toByteArray());
|
||||
- classNode.setExtendedClass(defineClass(
|
||||
+ classNode.setExtendedClass(loadClass(
|
||||
classNode.name.replace('/', '.'),
|
||||
classNode.getClassCode(),
|
||||
- classNode.getParentClass()
|
||||
+ classNode.getParentClass().getClassLoader()
|
||||
));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user