Sync from SUSE:ALP:Source:Standard:1.0 parboiled revision 23c15231289eee81c527ea58c1c7b641
This commit is contained in:
commit
a9c3d44be5
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
## Default LFS
|
||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
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.
BIN
parboiled-build.tar.xz
(Stored with Git LFS)
Normal file
BIN
parboiled-build.tar.xz
(Stored with Git LFS)
Normal file
Binary file not shown.
47
parboiled-core-1.4.1.pom
Normal file
47
parboiled-core-1.4.1.pom
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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-core</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||||
|
<url>http://parboiled.org</url>
|
||||||
|
<version>1.4.1</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-core</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.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.13</artifactId>
|
||||||
|
<version>3.2.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
72
parboiled-java-1.4.1.pom
Normal file
72
parboiled-java-1.4.1.pom
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?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-java</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||||
|
<url>http://parboiled.org</url>
|
||||||
|
<version>1.4.1</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-java</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.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<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.13</artifactId>
|
||||||
|
<version>3.2.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<version>9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm-tree</artifactId>
|
||||||
|
<version>9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm-analysis</artifactId>
|
||||||
|
<version>9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm-util</artifactId>
|
||||||
|
<version>9.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
57
parboiled-scala_2.13-1.4.1.pom
Normal file
57
parboiled-scala_2.13-1.4.1.pom
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?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.13</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful</description>
|
||||||
|
<url>http://parboiled.org</url>
|
||||||
|
<version>1.4.1</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.scala-lang</groupId>
|
||||||
|
<artifactId>scala-library</artifactId>
|
||||||
|
<version>2.13.8</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.parboiled</groupId>
|
||||||
|
<artifactId>parboiled-core</artifactId>
|
||||||
|
<version>1.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<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.13</artifactId>
|
||||||
|
<version>3.2.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
76
parboiled.changes
Normal file
76
parboiled.changes
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 15 14:23:14 UTC 2024 - Fridrich Strba <fstrba@suse.com>
|
||||||
|
|
||||||
|
- Remove the _multibuild file in order not to build unnecessary
|
||||||
|
parboiled:scala flavour
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
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>
|
||||||
|
|
||||||
|
- Build with source and target levels 1.8
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Dec 2 07:30:47 UTC 2019 - Fridrich Strba <fstrba@suse.com>
|
||||||
|
|
||||||
|
- Require scala >= 2.10.7 for build: allows buiding with jdk9+
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 27 06:37:29 UTC 2019 - Fridrich Strba <fstrba@suse.com>
|
||||||
|
|
||||||
|
- Split the scala subpackage from the main parboiled package in
|
||||||
|
order to split build dependencies: build them as _multibuild
|
||||||
|
package
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Apr 9 08:17:03 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
|
||||||
|
|
||||||
|
- Ensure neutrality of description.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Apr 3 09:09:39 UTC 2019 - Fridrich Strba <fstrba@suse.com>
|
||||||
|
|
||||||
|
- Initial packaging of parboiled 1.1.6
|
||||||
|
- Generate and customize ant build files
|
127
parboiled.spec
Normal file
127
parboiled.spec
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#
|
||||||
|
# spec file
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# upon. The license for this file, and modifications and additions to the
|
||||||
|
# file, is the same license as for the pristine package itself (unless the
|
||||||
|
# license for the pristine package is not an Open Source License, in which
|
||||||
|
# case the license is the MIT License). An "Open Source License" is a
|
||||||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
%global flavor @BUILD_FLAVOR@%{nil}
|
||||||
|
%if "%{flavor}" == "scala"
|
||||||
|
%bcond_without scala
|
||||||
|
%else
|
||||||
|
%bcond_with scala
|
||||||
|
%endif
|
||||||
|
%global scala_short_version 2.13
|
||||||
|
%global base_name parboiled
|
||||||
|
%if %{with scala}
|
||||||
|
Name: %{base_name}-scala
|
||||||
|
Summary: Parboiled for Scala
|
||||||
|
%else
|
||||||
|
Name: %{base_name}
|
||||||
|
Summary: Java library providing parsing of input text based on PEGs
|
||||||
|
%endif
|
||||||
|
Version: 1.4.1
|
||||||
|
Release: 0
|
||||||
|
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}-build.tar.xz
|
||||||
|
# for build see https://github.com/sirthias/parboiled/wiki/Building-parboiled
|
||||||
|
Source2: https://repo1.maven.org/maven2/org/parboiled/%{base_name}-core/%{version}/%{base_name}-core-%{version}.pom
|
||||||
|
Source3: https://repo1.maven.org/maven2/org/parboiled/%{base_name}-java/%{version}/%{base_name}-java-%{version}.pom
|
||||||
|
Source4: https://repo1.maven.org/maven2/org/parboiled/%{base_name}-scala_%{scala_short_version}/%{version}/%{base_name}-scala_%{scala_short_version}-%{version}.pom
|
||||||
|
Patch0: restore-java8-compatibility.patch
|
||||||
|
BuildRequires: ant
|
||||||
|
BuildRequires: fdupes
|
||||||
|
BuildRequires: java-devel >= 1.8
|
||||||
|
BuildRequires: javapackages-local >= 6
|
||||||
|
%if %{with scala}
|
||||||
|
BuildRequires: parboiled
|
||||||
|
BuildRequires: scala-ant
|
||||||
|
%else
|
||||||
|
BuildRequires: objectweb-asm
|
||||||
|
%endif
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description
|
||||||
|
%if %{with scala}
|
||||||
|
An internal Scala DSL for efficiently defining your parser rules.
|
||||||
|
|
||||||
|
%endif
|
||||||
|
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
|
||||||
|
and generally have some advantages over the "traditional" way of
|
||||||
|
building parser via CFGs.
|
||||||
|
|
||||||
|
%package javadoc
|
||||||
|
Summary: Javadoc for %{name}
|
||||||
|
Group: Documentation/HTML
|
||||||
|
|
||||||
|
%description javadoc
|
||||||
|
This package contains javadoc for %{base_name}.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -n %{base_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
|
||||||
|
|
||||||
|
%build
|
||||||
|
mkdir -p lib
|
||||||
|
build-jar-repository -s lib \
|
||||||
|
%if %{with scala}
|
||||||
|
%{base_name} scala
|
||||||
|
%else
|
||||||
|
objectweb-asm
|
||||||
|
%endif
|
||||||
|
%{ant} \
|
||||||
|
%if %{with scala}
|
||||||
|
-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}
|
||||||
|
for i in %{modules}; do
|
||||||
|
# jar
|
||||||
|
install -pm 0644 %{base_name}-${i}/target/%{base_name}-${i}*%{version}.jar %{buildroot}%{_javadir}/%{base_name}/${i}.jar
|
||||||
|
# pom
|
||||||
|
%{mvn_install_pom} %{base_name}-${i}/pom.xml %{buildroot}%{_mavenpomdir}/%{base_name}/${i}.pom
|
||||||
|
%add_maven_depmap %{base_name}/${i}.pom %{base_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}/
|
||||||
|
done
|
||||||
|
%fdupes -s %{buildroot}%{_javadocdir}
|
||||||
|
|
||||||
|
%files -f .mfiles
|
||||||
|
%doc CHANGELOG README.markdown
|
||||||
|
%license LICENSE
|
||||||
|
|
||||||
|
%files javadoc
|
||||||
|
%license LICENSE
|
||||||
|
%{_javadocdir}/%{base_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…
Reference in New Issue
Block a user