From 105667c6257f9287b80001c329f5523eb558a52086895b27b82d19945dc7006c Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 13 Feb 2024 01:50:55 +0000 Subject: [PATCH 1/4] OBS-URL: https://build.opensuse.org/package/show/Java:packages/ecj?expand=0&rev=65 --- ecj-java8compat.patch | 93 +++++++++++++++++++++++++++++++++++++++++++ ecj.changes | 7 ++++ ecj.spec | 4 +- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 ecj-java8compat.patch diff --git a/ecj-java8compat.patch b/ecj-java8compat.patch new file mode 100644 index 0000000..984f7d4 --- /dev/null +++ b/ecj-java8compat.patch @@ -0,0 +1,93 @@ +--- a/build.xml 2022-03-08 08:19:52.000000000 +0100 ++++ b/build.xml 2024-02-13 02:31:15.760059399 +0100 +@@ -26,8 +26,8 @@ + +- ++ source="8" target="8"> ++ + + + +--- a/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 ++++ b/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2024-02-13 02:40:37.158638361 +0100 +@@ -1281,7 +1281,7 @@ + private Iterable getFiles(final Iterable paths) { + if (paths == null) + return null; +- return () -> new Iterator<>() { ++ return () -> new Iterator() { + Iterator original = paths.iterator(); + @Override + public boolean hasNext() { +@@ -1296,7 +1296,7 @@ + private Iterable getPaths(final Iterable files) { + if (files == null) + return null; +- return () -> new Iterator<>() { ++ return () -> new Iterator() { + Iterator original = files.iterator(); + @Override + public boolean hasNext() { +--- a/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2022-03-08 08:19:50.000000000 +0100 ++++ b/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2024-02-13 02:32:54.251379205 +0100 +@@ -3319,7 +3319,7 @@ + } + } + // sort them in according to their own indexes +- Arrays.sort(bindings, new Comparator<>() { ++ Arrays.sort(bindings, new Comparator() { + @Override + public int compare(SyntheticMethodBinding o1, SyntheticMethodBinding o2) { + return o1.index - o2.index; +--- a/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2022-03-08 08:19:50.000000000 +0100 ++++ b/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2024-02-13 02:38:57.913975827 +0100 +@@ -239,7 +239,7 @@ + DiagnosticListener diagListener = EclipseCompilerImpl.this.diagnosticListener; + Diagnostic diagnostic = null; + if (diagListener != null) { +- diagnostic = new Diagnostic<>() { ++ diagnostic = new Diagnostic() { + @Override + public String getCode() { + return Integer.toString(problemId); +@@ -316,7 +316,7 @@ + DiagnosticListener diagListener = EclipseCompilerImpl.this.diagnosticListener; + Diagnostic diagnostic = null; + if (diagListener != null) { +- diagnostic = new Diagnostic<>() { ++ diagnostic = new Diagnostic() { + @Override + public String getCode() { + return Integer.toString(problemId); +@@ -797,7 +797,7 @@ + Iterator iterator = this.extraProblems.iterator(); iterator.hasNext(); ) { + final CategorizedProblem problem = (CategorizedProblem) iterator.next(); + if (this.diagnosticListener != null && !isIgnored(problem)) { +- Diagnostic diagnostic = new Diagnostic<>() { ++ Diagnostic diagnostic = new Diagnostic() { + @Override + public String getCode() { + return null; +--- a/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 ++++ b/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2024-02-13 02:41:33.840827055 +0100 +@@ -1310,7 +1310,7 @@ + private Iterable getFiles(final Iterable paths) { + if (paths == null) + return null; +- return () -> new Iterator<>() { ++ return () -> new Iterator() { + Iterator original = paths.iterator(); + @Override + public boolean hasNext() { +@@ -1325,7 +1325,7 @@ + private Iterable getPaths(final Iterable files) { + if (files == null) + return null; +- return () -> new Iterator<>() { ++ return () -> new Iterator() { + Iterator original = files.iterator(); + @Override + public boolean hasNext() { diff --git a/ecj.changes b/ecj.changes index 43a79fa..033e0aa 100644 --- a/ecj.changes +++ b/ecj.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Feb 13 01:50:04 UTC 2024 - Fridrich Strba + +- Added patch: + * ecj-java8compat.patch + + Allow building ecj with language levels 8 + ------------------------------------------------------------------- Mon Aug 21 11:46:03 UTC 2023 - Fridrich Strba diff --git a/ecj.spec b/ecj.spec index 8aeacf5..8f906a0 100644 --- a/ecj.spec +++ b/ecj.spec @@ -1,7 +1,7 @@ # # spec file for package ecj # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -32,6 +32,7 @@ Source1: https://repo1.maven.org/maven2/org/eclipse/jdt/ecj/%{bundle_ver} # Extracted from https://download.eclipse.org/eclipse/downloads/drops4/%%{drop}/ecj-%%{jar_ver}.jar Source2: MANIFEST.MF Patch0: ecj-rpmdebuginfo.patch +Patch1: ecj-java8compat.patch BuildRequires: ant BuildRequires: java-devel >= 11 BuildRequires: javapackages-local >= 6 @@ -45,6 +46,7 @@ the JDT Core batch compiler. %prep %setup -q -c %patch0 -p1 +%patch1 -p1 # Specify encoding sed -i -e '/compilerarg/s/Xlint:none/Xlint:none -encoding cp1252/' build.xml From 7b52197adec35c22bc65eb455aaca9253df4e4bedb4c14630db2b61af2696266 Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 13 Feb 2024 02:51:04 +0000 Subject: [PATCH 2/4] OBS-URL: https://build.opensuse.org/package/show/Java:packages/ecj?expand=0&rev=66 --- ecj-java8compat.patch | 8 +++++--- ecj.changes | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ecj-java8compat.patch b/ecj-java8compat.patch index 984f7d4..360885a 100644 --- a/ecj-java8compat.patch +++ b/ecj-java8compat.patch @@ -1,13 +1,15 @@ --- a/build.xml 2022-03-08 08:19:52.000000000 +0100 +++ b/build.xml 2024-02-13 02:31:15.760059399 +0100 -@@ -26,8 +26,8 @@ +@@ -25,9 +25,9 @@ + - ++ debug="true" encoding="utf-8" + source="8" target="8"> -+ ++ diff --git a/ecj.changes b/ecj.changes index 033e0aa..abf73bc 100644 --- a/ecj.changes +++ b/ecj.changes @@ -3,7 +3,7 @@ Tue Feb 13 01:50:04 UTC 2024 - Fridrich Strba - Added patch: * ecj-java8compat.patch - + Allow building ecj with language levels 8 + + Allow building ecj with language levels 8 (bsc#1219862) ------------------------------------------------------------------- Mon Aug 21 11:46:03 UTC 2023 - Fridrich Strba From bc1c06929ec9d1beda1ba55717c7ee35a20f0125ba59bc9ab5f5dca9312b6aa0 Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 13 Feb 2024 04:18:11 +0000 Subject: [PATCH 3/4] OBS-URL: https://build.opensuse.org/package/show/Java:packages/ecj?expand=0&rev=67 --- ecj-java8compat.patch | 93 ++++++++++++++++++++++++++++++++++++++----- ecj.spec | 2 + 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/ecj-java8compat.patch b/ecj-java8compat.patch index 360885a..475c33e 100644 --- a/ecj-java8compat.patch +++ b/ecj-java8compat.patch @@ -1,5 +1,5 @@ ---- a/build.xml 2022-03-08 08:19:52.000000000 +0100 -+++ b/build.xml 2024-02-13 02:31:15.760059399 +0100 +--- ecj-old/build.xml 2022-03-08 08:19:52.000000000 +0100 ++++ ecj-new/build.xml 2024-02-13 04:59:44.328387227 +0100 @@ -25,9 +25,9 @@ ---- a/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 -+++ b/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2024-02-13 02:40:37.158638361 +0100 +--- ecj-old/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 ++++ ecj-new/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java 2024-02-13 02:40:37.158638361 +0100 @@ -1281,7 +1281,7 @@ private Iterable getFiles(final Iterable paths) { if (paths == null) @@ -33,8 +33,8 @@ Iterator original = files.iterator(); @Override public boolean hasNext() { ---- a/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2022-03-08 08:19:50.000000000 +0100 -+++ b/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2024-02-13 02:32:54.251379205 +0100 +--- ecj-old/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2022-03-08 08:19:50.000000000 +0100 ++++ ecj-new/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 2024-02-13 02:32:54.251379205 +0100 @@ -3319,7 +3319,7 @@ } } @@ -44,8 +44,9 @@ @Override public int compare(SyntheticMethodBinding o1, SyntheticMethodBinding o2) { return o1.index - o2.index; ---- a/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2022-03-08 08:19:50.000000000 +0100 -+++ b/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2024-02-13 02:38:57.913975827 +0100 +diff -urEbwB ecj-old/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java ecj-new/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java +--- ecj-old/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2022-03-08 08:19:50.000000000 +0100 ++++ ecj-new/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 2024-02-13 02:38:57.913975827 +0100 @@ -239,7 +239,7 @@ DiagnosticListener diagListener = EclipseCompilerImpl.this.diagnosticListener; Diagnostic diagnostic = null; @@ -73,8 +74,9 @@ @Override public String getCode() { return null; ---- a/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 -+++ b/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2024-02-13 02:41:33.840827055 +0100 +diff -urEbwB ecj-old/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java ecj-new/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java +--- ecj-old/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2022-03-08 08:19:50.000000000 +0100 ++++ ecj-new/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java 2024-02-13 02:41:33.840827055 +0100 @@ -1310,7 +1310,7 @@ private Iterable getFiles(final Iterable paths) { if (paths == null) @@ -93,3 +95,74 @@ Iterator original = files.iterator(); @Override public boolean hasNext() { +--- ecj-old/org/eclipse/jdt/internal/compiler/util/Util.java 2022-03-08 08:19:52.000000000 +0100 ++++ ecj-new/org/eclipse/jdt/internal/compiler/util/Util.java 2024-02-13 04:59:18.222252584 +0100 +@@ -234,6 +234,7 @@ + String displayString(Object o); + } + ++ private static final int DEFAULT_READING_SIZE = 8192; + private static final int DEFAULT_WRITING_SIZE = 1024; + public final static String UTF_8 = "UTF-8"; //$NON-NLS-1$ + public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ +@@ -469,7 +470,41 @@ + * @throws IOException if a problem occurred reading the stream. + */ + public static byte[] getInputStreamAsByteArray(InputStream input) throws IOException { +- return input.readAllBytes(); // will have even slighly better performance as of JDK17+ see JDK-8264777 ++ byte[] contents = new byte[0]; ++ int contentsLength = 0; ++ int amountRead = -1; ++ do { ++ int amountRequested = Math.max(input.available(), DEFAULT_READING_SIZE); // read at least 8K ++ ++ // resize contents if needed ++ if (contentsLength + amountRequested > contents.length) { ++ System.arraycopy( ++ contents, ++ 0, ++ contents = new byte[contentsLength + amountRequested], ++ 0, ++ contentsLength); ++ } ++ ++ // read as many bytes as possible ++ amountRead = input.read(contents, contentsLength, amountRequested); ++ ++ if (amountRead > 0) { ++ // remember length of contents ++ contentsLength += amountRead; ++ } ++ } while (amountRead != -1); ++ ++ // resize contents if necessary ++ if (contentsLength < contents.length) { ++ System.arraycopy( ++ contents, ++ 0, ++ contents = new byte[contentsLength], ++ 0, ++ contentsLength); ++ } ++ return contents; + } + + +@@ -479,7 +514,16 @@ + * @throws IOException if a problem occurred reading the stream. + */ + public static byte[] readNBytes(InputStream input, int byteLength) throws IOException { +- return input.readNBytes(byteLength); ++ byte[] contents = new byte[byteLength]; ++ int len = 0; ++ int readSize = 0; ++ while ((readSize != -1) && (len != byteLength)) { ++ // See PR 1FMS89U ++ // We record first the read size. In this case len is the actual read size. ++ len += readSize; ++ readSize = input.read(contents, len, byteLength - len); ++ } ++ return contents; + } + + private static Map bomByEncoding = new HashMap(); diff --git a/ecj.spec b/ecj.spec index 8f906a0..fab1cdb 100644 --- a/ecj.spec +++ b/ecj.spec @@ -61,11 +61,13 @@ cp %{SOURCE2} scripts/binary/META-INF/MANIFEST.MF # jar install -dm 0755 %{buildroot}%{_javadir}/%{name} install -pm 0644 ecj.jar %{buildroot}%{_javadir}/%{name}/ecj.jar +install -pm 0644 javax17api.jar %{buildroot}%{_javadir}/%{name}/javax17api.jar # pom install -dm 0755 %{buildroot}%{_mavenpomdir}/%{name} %{mvn_install_pom} %{SOURCE1} %{buildroot}%{_mavenpomdir}/%{name}/ecj.pom %add_maven_depmap %{name}/ecj.pom %{name}/ecj.jar -a "org.eclipse.jdt:core,org.eclipse.jdt.core.compiler:ecj,org.eclipse.tycho:org.eclipse.jdt.core,org.eclipse.tycho:org.eclipse.jdt.compiler.apt" +%add_maven_depmap org.eclipse:javax17api:17 %{name}/javax17api.jar -a "org.eclipse:java9api,org.eclipse:java10api:org.eclipse:java15api" # Install the ecj wrapper script %jpackage_script org.eclipse.jdt.internal.compiler.batch.Main '' '' ecj ecj true From 0b19a6645f390a9c166c4f51c61f1575defdcecdc3cb7e73cd5f8b25a386c24a Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 13 Feb 2024 12:11:44 +0000 Subject: [PATCH 4/4] OBS-URL: https://build.opensuse.org/package/show/Java:packages/ecj?expand=0&rev=68 --- ecj.changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ecj.changes b/ecj.changes index abf73bc..2f575c9 100644 --- a/ecj.changes +++ b/ecj.changes @@ -4,6 +4,8 @@ Tue Feb 13 01:50:04 UTC 2024 - Fridrich Strba - Added patch: * ecj-java8compat.patch + Allow building ecj with language levels 8 (bsc#1219862) +- Distribute the bundled javax17api.jar under maven coordinate of + org.eclipse:javax17api:17, so that it can be used if needed ------------------------------------------------------------------- Mon Aug 21 11:46:03 UTC 2023 - Fridrich Strba