From 5cddb23261c3cb7c5d4caba3e3fe5bb9df998b7e Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sat, 18 May 2024 15:28:34 +0200 Subject: [PATCH 01/19] Register all polyglot java import classes for refective access --- build.sbt | 2 + .../org/enso/runner/EnsoLibraryFeature.java | 67 +++++++++++++++++++ .../org/enso/runner/native-image.properties | 1 + 3 files changed, 70 insertions(+) create mode 100644 engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java create mode 100644 engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/native-image.properties diff --git a/build.sbt b/build.sbt index 06345bff6290..d1860e4cf607 100644 --- a/build.sbt +++ b/build.sbt @@ -2433,6 +2433,7 @@ lazy val `engine-runner` = project // "-g", // "-H:+SourceLevelDebug", // "-H:-DeleteLocalSymbols", + // "--trace-class-initialization=org.enso.syntax2.Parser", "-Dnic=nic" ), mainClass = Some("org.enso.runner.Main"), @@ -2474,6 +2475,7 @@ lazy val `engine-runner` = project .dependsOn(`library-manager`) .dependsOn(`language-server`) .dependsOn(`edition-updater`) + .dependsOn(`runtime-parser`) .dependsOn(`logging-service`) .dependsOn(`logging-service-logback` % Runtime) .dependsOn(`polyglot-api`) diff --git a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java new file mode 100644 index 000000000000..cc02f12f3d05 --- /dev/null +++ b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java @@ -0,0 +1,67 @@ +package org.enso.runner; + +import static scala.jdk.javaapi.CollectionConverters.asJava; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.LinkedHashSet; +import org.enso.compiler.core.ir.module.scope.imports.Polyglot; +import org.enso.pkg.PackageManager$; +import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.RuntimeReflection; + +public final class EnsoLibraryFeature implements Feature { + + @Override + public void beforeAnalysis(BeforeAnalysisAccess access) { + var libs = new LinkedHashSet(); + for (var p : access.getApplicationClassPath()) { + var p1 = p.getParent(); + if (p1 != null && p1.getFileName().toString().equals("java")) { + var p2 = p1.getParent(); + if (p2 != null + && p2.getFileName().toString().equals("polyglot") + && p2.getParent() != null) { + libs.add(p2.getParent()); + } + } + } + + try (var parser = new org.enso.compiler.core.EnsoParser()) { + for (var p : libs) { + var result = PackageManager$.MODULE$.Default().loadPackage(p.toFile()); + if (result.isSuccess()) { + var pkg = result.get(); + for (var src : pkg.listSourcesJava()) { + var code = Files.readString(src.file().toPath()); + var ir = parser.compile(code); + for (var imp : asJava(ir.imports())) { + if (imp instanceof Polyglot poly && poly.entity() instanceof Polyglot.Java entity) { + var name = new StringBuilder(entity.getJavaName()); + Class clazz; + for (; ; ) { + clazz = access.findClassByName(name.toString()); + if (clazz != null) { + break; + } + int at = name.toString().lastIndexOf('.'); + if (at < 0) { + throw new IllegalStateException("Cannot load " + entity.getJavaName()); + } + name.setCharAt(at, '$'); + } + + RuntimeReflection.registerAllConstructors(clazz); + RuntimeReflection.registerAllFields(clazz); + RuntimeReflection.registerAllMethods(clazz); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + throw new IllegalStateException(ex); + } + } +} diff --git a/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/native-image.properties b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/native-image.properties new file mode 100644 index 000000000000..9e58138f6461 --- /dev/null +++ b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/native-image.properties @@ -0,0 +1 @@ +Args=--features=org.enso.runner.EnsoLibraryFeature From 773af10bf3bb8ef5ae6b47166342697aea21d136 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 15:24:51 +0200 Subject: [PATCH 02/19] org.enso.syntax2.Parser may be loaded during image build time now --- build.sbt | 2 +- .../parser/generate-java/java/org/enso/syntax2/Parser.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index d1860e4cf607..146db6546780 100644 --- a/build.sbt +++ b/build.sbt @@ -2433,6 +2433,7 @@ lazy val `engine-runner` = project // "-g", // "-H:+SourceLevelDebug", // "-H:-DeleteLocalSymbols", + // you may need to set smallJdk := None to use following flags: // "--trace-class-initialization=org.enso.syntax2.Parser", "-Dnic=nic" ), @@ -2441,7 +2442,6 @@ lazy val `engine-runner` = project "org.jline.nativ.JLineLibrary", "org.jline.terminal.impl.jna", "io.methvin.watchservice.jna.CarbonAPI", - "org.enso.syntax2.Parser", "zio.internal.ZScheduler$$anon$4", "org.enso.runner.Main$", "sun.awt", diff --git a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java index 818a45d36f76..26fde4cc6b80 100644 --- a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java +++ b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java @@ -7,7 +7,7 @@ import java.nio.charset.StandardCharsets; public final class Parser implements AutoCloseable { - static { + private static void initializeLibraries() { String os = System.getProperty("os.name"); String name; if (os.startsWith("Mac")) { @@ -77,6 +77,7 @@ private Parser(long stateIn) { static native long getUuidLow(long metadata, long codeOffset, long codeLength); public static Parser create() { + initializeLibraries(); var state = allocState(); return new Parser(state); } From e70f53adf49bc3964e13997318f210c0ec251e3e Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 15:25:41 +0200 Subject: [PATCH 03/19] Print out summary in EnsoLibraryFeature --- .../java/org/enso/runner/EnsoLibraryFeature.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java index cc02f12f3d05..e546220dbbd9 100644 --- a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java +++ b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java @@ -5,13 +5,13 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.LinkedHashSet; +import java.util.TreeSet; import org.enso.compiler.core.ir.module.scope.imports.Polyglot; import org.enso.pkg.PackageManager$; import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; public final class EnsoLibraryFeature implements Feature { - @Override public void beforeAnalysis(BeforeAnalysisAccess access) { var libs = new LinkedHashSet(); @@ -27,6 +27,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } } + var classes = new TreeSet(); try (var parser = new org.enso.compiler.core.EnsoParser()) { for (var p : libs) { var result = PackageManager$.MODULE$.Default().loadPackage(p.toFile()); @@ -50,7 +51,11 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } name.setCharAt(at, '$'); } - + classes.add(clazz.getName()); + RuntimeReflection.register(clazz); + RuntimeReflection.register(clazz.getConstructors()); + RuntimeReflection.register(clazz.getMethods()); + RuntimeReflection.register(clazz.getFields()); RuntimeReflection.registerAllConstructors(clazz); RuntimeReflection.registerAllFields(clazz); RuntimeReflection.registerAllMethods(clazz); @@ -63,5 +68,10 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { ex.printStackTrace(); throw new IllegalStateException(ex); } + System.err.println("Summary for polyglot import java:"); + for (var className : classes) { + System.err.println(" " + className); + } + System.err.println("Registered " + classes.size() + " classes for reflection"); } } From ee24418cd54f31d009cc0ce1f509deeabc708091 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 15:26:25 +0200 Subject: [PATCH 04/19] Don't initialize HttpClient in static class initializer --- .../java/org/enso/base/enso_cloud/audit/AuditLogAPI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/std-bits/base/src/main/java/org/enso/base/enso_cloud/audit/AuditLogAPI.java b/std-bits/base/src/main/java/org/enso/base/enso_cloud/audit/AuditLogAPI.java index 302027aa24fa..9383eee86735 100644 --- a/std-bits/base/src/main/java/org/enso/base/enso_cloud/audit/AuditLogAPI.java +++ b/std-bits/base/src/main/java/org/enso/base/enso_cloud/audit/AuditLogAPI.java @@ -22,8 +22,7 @@ class AuditLogAPI { private static final Logger logger = Logger.getLogger(AuditLogAPI.class.getName()); public static AuditLogAPI INSTANCE = new AuditLogAPI(); - private final HttpClient httpClient = - HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build(); + private HttpClient httpClient; private final ExecutorService executorService; private AuditLogAPI() { @@ -70,6 +69,9 @@ private HttpRequest buildRequest(LogMessage message) { private void sendLogRequest(HttpRequest request, int retryCount) throws RequestFailureException { try { try { + if (httpClient == null) { + httpClient = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build(); + } HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() < 200 || response.statusCode() >= 300) { From 6886b12409e66f869faf32bb51a9353855d86d11 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 15:26:56 +0200 Subject: [PATCH 05/19] Simpler and less verbose lookupJavaClass --- .../enso/interpreter/runtime/EnsoContext.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java index e664ff8ba34d..aa3f468d2b3c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -522,34 +521,35 @@ public boolean isColorTerminalOutput() { */ @TruffleBoundary public Object lookupJavaClass(String className) { - var items = Arrays.asList(className.split("\\.")); + var binaryName = new StringBuilder(className); var collectedExceptions = new ArrayList(); - for (int i = items.size() - 1; i >= 0; i--) { - String pkgName = String.join(".", items.subList(0, i)); - String curClassName = items.get(i); - List nestedClassPart = - i < items.size() - 1 ? items.subList(i + 1, items.size()) : List.of(); + for (; ; ) { + var fqn = binaryName.toString(); try { - var hostSymbol = lookupHostSymbol(pkgName, curClassName); - if (nestedClassPart.isEmpty()) { + var hostSymbol = lookupHostSymbol(fqn); + if (hostSymbol != null) { return hostSymbol; - } else { - var fullInnerClassName = curClassName + "$" + String.join("$", nestedClassPart); - return lookupHostSymbol(pkgName, fullInnerClassName); } } catch (ClassNotFoundException | RuntimeException | InteropException ex) { collectedExceptions.add(ex); } + var at = fqn.lastIndexOf('.'); + if (at < 0) { + break; + } + binaryName.setCharAt(at, '$'); } + var level = Level.WARNING; for (var ex : collectedExceptions) { - logger.log(Level.WARNING, null, ex); + logger.log(level, ex.getMessage()); + level = Level.FINE; + logger.log(Level.FINE, null, ex); } return null; } - private Object lookupHostSymbol(String pkgName, String curClassName) + private Object lookupHostSymbol(String fqn) throws ClassNotFoundException, UnknownIdentifierException, UnsupportedMessageException { - var fqn = pkgName + "." + curClassName; try { if (findGuestJava() == null) { return environment.asHostSymbol(hostClassLoader.loadClass(fqn)); From 6f3bfad38bd6cbecb1ed778ad980f250b4c0fe3b Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 17:10:24 +0200 Subject: [PATCH 06/19] Test native-image to include instance methods of additional classes --- .../Base/0.0.0-dev/src/Data/Text/Extensions.enso | 7 +++++-- .../Standard/Test/0.0.0-dev/src/Test_Reporter.enso | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index f3716c47f387..0dab00afa906 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -45,6 +45,8 @@ polyglot java import java.lang.StringBuilder polyglot java import org.enso.base.Encoding_Utils polyglot java import org.enso.base.Regex_Utils polyglot java import org.enso.base.Text_Utils +polyglot java import org.enso.base.text.Utf16Span +polyglot java import org.enso.base.text.GraphemeSpan ## GROUP Text ICON text @@ -392,7 +394,8 @@ Text.split self delimiter="," case_sensitivity=Case_Sensitivity.Sensitive use_re start = if i == 0 then 0 else delimiters.at i-1 . codeunit_end end = if i == delimiters.length then (Text_Utils.char_length self) else - delimiters.at i . codeunit_start + span = delimiters.at i + (span : Utf16Span) . codeunit_start Text_Utils.substring self start end True -> case delimiter of _ : Text -> @@ -1312,7 +1315,7 @@ Text.locate self term="" mode=Matching_Mode.First case_sensitivity=Case_Sensitiv case Text_Utils.span_of_case_insensitive self term locale.java_locale search_for_last of Nothing -> Nothing grapheme_span -> - Span.Value (grapheme_span.grapheme_start.up_to grapheme_span.grapheme_end) self + Span.Value ((grapheme_span:GraphemeSpan).grapheme_start.up_to grapheme_span.grapheme_end) self ## ALIAS index_of_all, position_of_all, span_of_all GROUP Text diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso index 73e1539cb915..79b6ef2bdb3d 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso @@ -14,6 +14,7 @@ import project.Test_Result.Test_Result polyglot java import java.lang.StringBuilder polyglot java import java.lang.System as Java_System +polyglot java import java.io.PrintStream ## PRIVATE Write the JUnit XML header. @@ -193,11 +194,12 @@ print_progress current_progress total_count status_text = truncated_line = if line.length <= progress_width then line else line.take (progress_width - 3) + '...' - Java_System.out.print '\r' - Java_System.out.print (' ' * progress_width) - Java_System.out.print '\r' - Java_System.out.print truncated_line - Java_System.out.print '\r' + ps = Java_System.out : PrintStream + ps.print '\r' + ps.print (' ' * progress_width) + ps.print '\r' + ps.print truncated_line + ps.print '\r' ## PRIVATE clear_progress = From e409b0022b5f57b1f266acd46ca96999741d900e Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 17:40:22 +0200 Subject: [PATCH 07/19] Right now we only analyze Standard.Base --- .../lib/Standard/Base/0.0.0-dev/src/IO.enso | 3 +++ .../Test/0.0.0-dev/src/Test_Reporter.enso | 12 +++++------- .../java/org/enso/runner/EnsoLibraryFeature.java | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso index 900a61caf36e..340cd1e0bbfe 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso @@ -2,6 +2,9 @@ import project.Any.Any import project.Data.Text.Text import project.Nothing.Nothing +# needed for Standard.Test.Test_Reporter +polyglot java import java.io.PrintStream + ## PRIVATE ADVANCED Prints the provided message to standard error. diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso index 79b6ef2bdb3d..73e1539cb915 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test_Reporter.enso @@ -14,7 +14,6 @@ import project.Test_Result.Test_Result polyglot java import java.lang.StringBuilder polyglot java import java.lang.System as Java_System -polyglot java import java.io.PrintStream ## PRIVATE Write the JUnit XML header. @@ -194,12 +193,11 @@ print_progress current_progress total_count status_text = truncated_line = if line.length <= progress_width then line else line.take (progress_width - 3) + '...' - ps = Java_System.out : PrintStream - ps.print '\r' - ps.print (' ' * progress_width) - ps.print '\r' - ps.print truncated_line - ps.print '\r' + Java_System.out.print '\r' + Java_System.out.print (' ' * progress_width) + Java_System.out.print '\r' + Java_System.out.print truncated_line + Java_System.out.print '\r' ## PRIVATE clear_progress = diff --git a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java index e546220dbbd9..86a7cddadbb1 100644 --- a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java +++ b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java @@ -27,6 +27,22 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } } + /* + To run Standard.Test one shall analyze its polyglot/java files. But there are none + to include on classpath as necessary test classes are included in Standard.Base! + We can locate the Test library by following code or we can make sure all necessary + imports are already mentioned in Standard.Base itself. + + if (!libs.isEmpty()) { + var f = libs.iterator().next(); + var stdTest = f.getParent().getParent().resolve("Test").resolve(f.getFileName()); + if (stdTest.toFile().exists()) { + libs.add(stdTest); + } + System.err.println("Testing library: " + stdTest); + } + */ + var classes = new TreeSet(); try (var parser = new org.enso.compiler.core.EnsoParser()) { for (var p : libs) { From e9551b7e621b05d880dfd61ec7b647a6a60e5119 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 17:42:07 +0200 Subject: [PATCH 08/19] Don't use asGuestValue in GetSourceLocationNode --- .../generic/GetSourceLocationNode.java | 3 +- .../interpreter/runtime/data/EnsoSource.java | 74 +++++++++---- .../runtime/data/EnsoSourceSection.java | 104 ++++++++++-------- 3 files changed, 111 insertions(+), 70 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/generic/GetSourceLocationNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/generic/GetSourceLocationNode.java index 88a43b238501..cb96b6ee92d2 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/generic/GetSourceLocationNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/generic/GetSourceLocationNode.java @@ -23,8 +23,7 @@ public class GetSourceLocationNode extends Node { Object execute(Object value) { try { - return EnsoContext.get(this) - .asGuestValue(new EnsoSourceSection(library.getSourceLocation(value))); + return new EnsoSourceSection(library.getSourceLocation(value)); } catch (UnsupportedMessageException e) { err.enter(); Builtins builtins = EnsoContext.get(this).getBuiltins(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSource.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSource.java index 9dba83b3d8ee..fae77b1e7697 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSource.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSource.java @@ -1,44 +1,72 @@ package org.enso.interpreter.runtime.data; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.source.Source; +import org.enso.interpreter.runtime.EnsoContext; +import org.enso.interpreter.runtime.data.text.Text; +import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers; /** Wrapper for exposing sources to Enso. Delegates to original methods with no behavior changes. */ -public class EnsoSource { +@ExportLibrary(InteropLibrary.class) +public final class EnsoSource implements EnsoObject { + private static final String[] MEMBERS = { + "getLanguage", // + "getName", // + "getPath", // + "isInternal", // + "getCharacters", // + "getLength", // + "getLineCount", // + }; private final Source source; public EnsoSource(Source source) { this.source = source; } - public String getLanguage() { - return source.getLanguage(); - } - - public String getName() { - return source.getName(); - } - - public String getPath() { - return source.getPath(); - } - - public boolean isInternal() { - return source.isInternal(); + /* + public CharSequence getCharacters(int lineNumber) { + return source.getCharacters(lineNumber); } + */ - public CharSequence getCharacters() { - return source.getCharacters(); + @ExportMessage + boolean hasMembers() { + return true; } - public int getLength() { - return source.getLength(); + @TruffleBoundary + @ExportMessage + Object readMember(String name, @CachedLibrary("this") InteropLibrary node) { + return switch (name) { + case "getLanguage" -> Text.create(source.getLanguage()); + case "getName" -> Text.create(source.getName()); + case "getPath" -> Text.create(source.getPath()); + case "isInternal" -> source.isInternal(); + case "getCharacters" -> Text.create(source.getCharacters().toString()); + case "getLength" -> source.getLength(); + case "getLineCount" -> source.getLineCount(); + default -> throw EnsoContext.get(node).raiseAssertionPanic(node, name, null); + }; } - public CharSequence getCharacters(int lineNumber) { - return source.getCharacters(lineNumber); + @ExportMessage + @TruffleBoundary + boolean isMemberReadable(String name) { + for (var n : MEMBERS) { + if (name.equals(n)) { + return true; + } + } + return false; } - public int getLineCount() { - return source.getLineCount(); + @ExportMessage + Object getMembers(boolean includeInternal) { + return ArrayLikeHelpers.wrapStrings(MEMBERS); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSourceSection.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSourceSection.java index f35bc2a081dc..a15ab53416a7 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSourceSection.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoSourceSection.java @@ -1,67 +1,81 @@ package org.enso.interpreter.runtime.data; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.source.SourceSection; +import org.enso.interpreter.runtime.EnsoContext; +import org.enso.interpreter.runtime.data.text.Text; +import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers; /** * Wrapper for exposing source sections in Enso. Delegates to the original methods with no behaviour * changes. */ -public class EnsoSourceSection { +@ExportLibrary(InteropLibrary.class) +public final class EnsoSourceSection implements EnsoObject { + private static final String[] MEMBERS = { + "getStartLine", // + "getEndLine", // + "getEndColumn", // + "getCharIndex", // + "getCharLength", // + "getCharEndIndex", // + "getCharacters", // + "getStartColumn", // + "isAvailable", // + "hasLines", // + "hasColumns", // + "hasCharIndex", // + "getSource", // + }; private final SourceSection sourceSection; public EnsoSourceSection(SourceSection sourceSection) { this.sourceSection = sourceSection; } - public int getStartLine() { - return sourceSection.getStartLine(); + @ExportMessage + boolean hasMembers() { + return true; } - public int getEndLine() { - return sourceSection.getEndLine(); + @TruffleBoundary + @ExportMessage + Object readMember(String name, @CachedLibrary("this") InteropLibrary node) { + return switch (name) { + case "getStartLine" -> sourceSection.getStartLine(); + case "getEndLine" -> sourceSection.getEndLine(); + case "getEndColumn" -> sourceSection.getEndColumn(); + case "getCharIndex" -> sourceSection.getCharIndex(); + case "getCharLength" -> sourceSection.getCharLength(); + case "getCharEndIndex" -> sourceSection.getCharEndIndex(); + case "getCharacters" -> Text.create(sourceSection.getCharacters().toString()); + case "getStartColumn" -> sourceSection.getStartColumn(); + case "isAvailable" -> sourceSection.isAvailable(); + case "hasLines" -> sourceSection.hasLines(); + case "hasColumns" -> sourceSection.hasColumns(); + case "hasCharIndex" -> sourceSection.hasCharIndex(); + case "getSource" -> new EnsoSource(sourceSection.getSource()); + default -> throw EnsoContext.get(node).raiseAssertionPanic(node, name, null); + }; } - public int getEndColumn() { - return sourceSection.getEndColumn(); + @ExportMessage + @TruffleBoundary + boolean isMemberReadable(String name) { + for (var n : MEMBERS) { + if (name.equals(n)) { + return true; + } + } + return false; } - public int getCharIndex() { - return sourceSection.getCharIndex(); - } - - public int getCharLength() { - return sourceSection.getCharLength(); - } - - public int getCharEndIndex() { - return sourceSection.getCharEndIndex(); - } - - public CharSequence getCharacters() { - return sourceSection.getCharacters(); - } - - public int getStartColumn() { - return sourceSection.getStartColumn(); - } - - public boolean isAvailable() { - return sourceSection.isAvailable(); - } - - public boolean hasLines() { - return sourceSection.hasLines(); - } - - public boolean hasColumns() { - return sourceSection.hasColumns(); - } - - public boolean hasCharIndex() { - return sourceSection.hasCharIndex(); - } - - public EnsoSource getSource() { - return new EnsoSource(sourceSection.getSource()); + @ExportMessage + Object getMembers(boolean includeInternal) { + return ArrayLikeHelpers.wrapStrings(MEMBERS); } } From e9a55f09272efc9eeecd7afd2d2fd99e824799c3 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 17:42:48 +0200 Subject: [PATCH 09/19] Report missing Java classes as DataflowError --- .../interpreter/runtime/IrToTruffle.scala | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala b/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala index abdb0aef1991..6870809e2b7d 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala @@ -115,6 +115,7 @@ import scala.collection.mutable import scala.collection.mutable.ArrayBuffer import scala.jdk.CollectionConverters._ import scala.jdk.OptionConverters._ +import org.enso.interpreter.runtime.error.DataflowError /** This is an implementation of a codegeneration pass that lowers the Enso * [[IR]] into the truffle structures that are actually executed. @@ -231,17 +232,17 @@ class IrToTruffle( // Register the imports in scope importDefs.foreach { case poly @ imports.Polyglot(i: imports.Polyglot.Java, _, _, _, _) => - val hostSymbol = context.lookupJavaClass(i.getJavaName) - if (hostSymbol != null) { - this.moduleScope.registerPolyglotSymbol( - poly.getVisibleName, - hostSymbol - ) - } else { - throw new CompilerError( - s"Incorrect polyglot import: Cannot find host symbol (Java class) '${i.getJavaName}'" + var hostSymbol = context.lookupJavaClass(i.getJavaName) + if (hostSymbol == null) { + val err = Text.create( + s"Incorrect polyglot java import: ${i.getJavaName}" ) + hostSymbol = DataflowError.withoutTrace(err, null) } + this.moduleScope.registerPolyglotSymbol( + poly.getVisibleName, + hostSymbol + ) case _: Import.Module => case _: Error => } From 5cc50de96ae756d73278679a7b8186dfc227184a Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 19 May 2024 18:12:13 +0200 Subject: [PATCH 10/19] Execute all Text. tests in CI --- build/build/src/engine/context.rs | 7 +++++++ test/Base_Tests/src/Data/Text_Spec.enso | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 3a9f66523023..63e6523410f7 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -649,5 +649,12 @@ pub async fn runner_sanity_test( output.contains(factorial_expected_output), "Native runner output does not contain expected result '{factorial_expected_output}'. Output:\n{output}", ); + let test_base = Command::new(&repo_root.runner) + .args(["--run", repo_root.test.join("Base_Tests").as_str(), "Test\\."]) + .set_env_opt(ENSO_JAVA, enso_java)? + .set_env(ENSO_DATA_DIRECTORY, engine_package)? + .run_stdout() + .await?; + ensure!(test_base.contains("0 tests failed."), "All tests shall succeed. Output:\n{test_base}",); Ok(()) } diff --git a/test/Base_Tests/src/Data/Text_Spec.enso b/test/Base_Tests/src/Data/Text_Spec.enso index 8e48d42f1c61..eda341bce62f 100644 --- a/test/Base_Tests/src/Data/Text_Spec.enso +++ b/test/Base_Tests/src/Data/Text_Spec.enso @@ -62,7 +62,7 @@ add_specs suite_builder = accent_1 = '\u00E9' accent_2 = '\u0065\u{301}' - suite_builder.group "Text" group_builder-> + suite_builder.group "Text.general" group_builder-> kshi = '\u0915\u094D\u0937\u093F' facepalm = '\u{1F926}\u{1F3FC}\u200D\u2642\uFE0F' utf_8_whitespace = 'foo\n bar baz \u202F quux' @@ -1354,7 +1354,7 @@ add_specs suite_builder = txt.find "a[bc]" . text 0 . should_equal "ab" txt.find_all "a[bc]" . map (match-> match.text 0) . should_equal ["ab", "ac"] - suite_builder.group "Regex: find and find_all" group_builder-> + suite_builder.group "Text.Regex: find and find_all" group_builder-> group_builder.specify "should be possible on text" <| "My Text: Goes Here".find "^My Text: (.+)$" . text 0 . should_equal "My Text: Goes Here" @@ -1476,7 +1476,7 @@ add_specs suite_builder = locale = Locale.new "en" "GB" "UTF-8" 'a'.match 'a' case_sensitivity=(Case_Sensitivity.Insensitive locale) . should_fail_with Illegal_Argument - suite_builder.group "Regex splitting" group_builder-> + suite_builder.group "Text.Regex splitting" group_builder-> group_builder.specify "should be possible on text" <| splits = "abcde".split "[bd]" use_regex=True splits.length . should_equal 3 @@ -1498,7 +1498,7 @@ add_specs suite_builder = splits.at 1 . should_equal "a" splits.at 2 . should_equal "a" - suite_builder.group "Regex tokenizing" group_builder-> + suite_builder.group "Text.Regex tokenizing" group_builder-> group_builder.specify "can tokenize with simple regexes without capturing groups" "1-800-regex-yes" . tokenize "[a-z]+" . should_equal ["regex", "yes"] "1-800-REGEX-YES" . tokenize "[a-z]+" case_sensitivity=Case_Sensitivity.Insensitive . should_equal ["REGEX", "YES"] From 8ab93628485728d5882afe9354a3ec58b3b983ab Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 06:44:37 +0200 Subject: [PATCH 11/19] Initialize Parser before executing the tests --- lib/rust/parser/generate-java/src/bin/java-tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rust/parser/generate-java/src/bin/java-tests.rs b/lib/rust/parser/generate-java/src/bin/java-tests.rs index e664e7b965e4..daf00cc87dd7 100644 --- a/lib/rust/parser/generate-java/src/bin/java-tests.rs +++ b/lib/rust/parser/generate-java/src/bin/java-tests.rs @@ -28,6 +28,7 @@ fn main() { println!("import java.nio.ByteOrder;"); println!(); println!("class GeneratedFormatTests {{"); + println!(" private static final Object INIT = {package}.Parser.create();"); println!(" private static java.util.Vector accept;"); println!(" private static java.util.Vector reject;"); for (i, case) in cases.accept.iter().enumerate() { From da144be1efae4d246bd7bb029fb65992ab6cfa86 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 07:14:02 +0200 Subject: [PATCH 12/19] License framework believes guava and checkerframework are gone from the engine --- distribution/engine/THIRD-PARTY/NOTICE | 25 -- .../NOTICES | 9 - .../NOTICES | 13 - .../com.google.guava.guava-32.0.0-jre/NOTICES | 5 - .../NOTICES | 1 - .../LICENSE.txt | 22 - .../LICENSE.txt.1 | 414 ------------------ .../NOTICES | 5 - .../copyright-keep | 5 - .../copyright-keep-context | 1 - .../copyright-ignore | 19 - .../copyright-keep | 3 - .../files-ignore | 1 - .../copyright-keep | 1 - .../copyright-add | 4 - .../custom-license | 1 - .../files-add/LICENSE.txt | 414 ------------------ .../files-keep | 1 - tools/legal-review/engine/report-state | 4 +- 19 files changed, 2 insertions(+), 946 deletions(-) delete mode 100644 distribution/engine/THIRD-PARTY/com.google.errorprone.error_prone_annotations-2.18.0/NOTICES delete mode 100644 distribution/engine/THIRD-PARTY/com.google.guava.failureaccess-1.0.1/NOTICES delete mode 100644 distribution/engine/THIRD-PARTY/com.google.guava.guava-32.0.0-jre/NOTICES delete mode 100644 distribution/engine/THIRD-PARTY/com.google.j2objc.j2objc-annotations-2.8/NOTICES delete mode 100644 distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt delete mode 100644 distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt.1 delete mode 100644 distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/NOTICES delete mode 100644 tools/legal-review/engine/com.google.errorprone.error_prone_annotations-2.18.0/copyright-keep delete mode 100644 tools/legal-review/engine/com.google.guava.failureaccess-1.0.1/copyright-keep-context delete mode 100644 tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-ignore delete mode 100644 tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-keep delete mode 100644 tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/files-ignore delete mode 100644 tools/legal-review/engine/com.google.j2objc.j2objc-annotations-2.8/copyright-keep delete mode 100644 tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/copyright-add delete mode 100644 tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/custom-license delete mode 100644 tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-add/LICENSE.txt delete mode 100644 tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-keep diff --git a/distribution/engine/THIRD-PARTY/NOTICE b/distribution/engine/THIRD-PARTY/NOTICE index ec6045ddfe21..07e1563d71b0 100644 --- a/distribution/engine/THIRD-PARTY/NOTICE +++ b/distribution/engine/THIRD-PARTY/NOTICE @@ -46,31 +46,11 @@ The license information can be found along with the copyright notices. Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.module.jackson-module-scala_2.13-2.15.2`. -'error_prone_annotations', licensed under the Apache 2.0, is distributed with the engine. -The license file can be found at `licenses/APACHE2.0`. -Copyright notices related to this dependency can be found in the directory `com.google.errorprone.error_prone_annotations-2.18.0`. - - 'flatbuffers-java', licensed under the Apache License V2.0, is distributed with the engine. The license file can be found at `licenses/APACHE2.0`. Copyright notices related to this dependency can be found in the directory `com.google.flatbuffers.flatbuffers-java-24.3.25`. -'failureaccess', licensed under the The Apache Software License, Version 2.0, is distributed with the engine. -The license file can be found at `licenses/APACHE2.0`. -Copyright notices related to this dependency can be found in the directory `com.google.guava.failureaccess-1.0.1`. - - -'guava', licensed under the Apache License, Version 2.0, is distributed with the engine. -The license file can be found at `licenses/APACHE2.0`. -Copyright notices related to this dependency can be found in the directory `com.google.guava.guava-32.0.0-jre`. - - -'j2objc-annotations', licensed under the Apache License, Version 2.0, is distributed with the engine. -The license file can be found at `licenses/APACHE2.0`. -Copyright notices related to this dependency can be found in the directory `com.google.j2objc.j2objc-annotations-2.8`. - - 'JavaEWAH', licensed under the Apache 2, is distributed with the engine. The license file can be found at `licenses/APACHE2.0`. Copyright notices related to this dependency can be found in the directory `com.googlecode.javaewah.JavaEWAH-1.2.3`. @@ -311,11 +291,6 @@ The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcutil-jdk18on-1.76`. -'checker-qual', licensed under the The MIT License, is distributed with the engine. -The license information can be found along with the copyright notices. -Copyright notices related to this dependency can be found in the directory `org.checkerframework.checker-qual-3.33.0`. - - 'org.eclipse.jgit', licensed under the Eclipse Distribution License (New BSD License), is distributed with the engine. The license file can be found at `licenses/Eclipse_Distribution_License_(New_BSD_License)`. Copyright notices related to this dependency can be found in the directory `org.eclipse.jgit.org.eclipse.jgit-6.7.0.202309050840-r`. diff --git a/distribution/engine/THIRD-PARTY/com.google.errorprone.error_prone_annotations-2.18.0/NOTICES b/distribution/engine/THIRD-PARTY/com.google.errorprone.error_prone_annotations-2.18.0/NOTICES deleted file mode 100644 index 61b725caf204..000000000000 --- a/distribution/engine/THIRD-PARTY/com.google.errorprone.error_prone_annotations-2.18.0/NOTICES +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2014 The Error Prone Authors. - -Copyright 2015 The Error Prone Authors. - -Copyright 2016 The Error Prone Authors. - -Copyright 2017 The Error Prone Authors. - -Copyright 2021 The Error Prone Authors. diff --git a/distribution/engine/THIRD-PARTY/com.google.guava.failureaccess-1.0.1/NOTICES b/distribution/engine/THIRD-PARTY/com.google.guava.failureaccess-1.0.1/NOTICES deleted file mode 100644 index 5c779f6eb124..000000000000 --- a/distribution/engine/THIRD-PARTY/com.google.guava.failureaccess-1.0.1/NOTICES +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (C) 2018 The Guava Authors - * - * 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. - */ diff --git a/distribution/engine/THIRD-PARTY/com.google.guava.guava-32.0.0-jre/NOTICES b/distribution/engine/THIRD-PARTY/com.google.guava.guava-32.0.0-jre/NOTICES deleted file mode 100644 index 8095fdbd215a..000000000000 --- a/distribution/engine/THIRD-PARTY/com.google.guava.guava-32.0.0-jre/NOTICES +++ /dev/null @@ -1,5 +0,0 @@ -Copyright (C) 2021 The Guava Authors - -Copyright 2011 Google Inc. All Rights Reserved. - -domain. The author hereby disclaims copyright to this source code. diff --git a/distribution/engine/THIRD-PARTY/com.google.j2objc.j2objc-annotations-2.8/NOTICES b/distribution/engine/THIRD-PARTY/com.google.j2objc.j2objc-annotations-2.8/NOTICES deleted file mode 100644 index 0b517a543509..000000000000 --- a/distribution/engine/THIRD-PARTY/com.google.j2objc.j2objc-annotations-2.8/NOTICES +++ /dev/null @@ -1 +0,0 @@ -Copyright 2012 Google Inc. All Rights Reserved. diff --git a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt b/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt deleted file mode 100644 index 9837c6b69fda..000000000000 --- a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Checker Framework qualifiers -Copyright 2004-present by the Checker Framework developers - -MIT License: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt.1 b/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt.1 deleted file mode 100644 index 70d6a70fe2fb..000000000000 --- a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/LICENSE.txt.1 +++ /dev/null @@ -1,414 +0,0 @@ -The Checker Framework -Copyright 2004-present by the Checker Framework developers - - -Most of the Checker Framework is licensed under the GNU General Public -License, version 2 (GPL2), with the classpath exception. The text of this -license appears below. This is the same license used for OpenJDK. - -A few parts of the Checker Framework have more permissive licenses, notably -the parts that you might want to include with your own program. - - * The annotations and utility files are licensed under the MIT License. - (The text of this license also appears below.) This applies to the - checker-qual*.jar and all the files that appear in it: every file in a - qual/ directory, plus utility files FormatUtil.java, - I18nFormatUtil.java, NullnessUtil.java, Opt.java, PurityUnqualified.java, - RegexUtil.java, SignednessUtil.java, SignednessUtilExtra.java, and - UnitsTools.java. It also applies to the cleanroom implementations of - third-party annotations (in checker/src/testannotations/ and in - framework/src/main/java/org/jmlspecs/). - -The Checker Framework includes annotations for some libraries. Those in -.astub files use the MIT License. Those in https://github.com/typetools/jdk -(which appears in the annotated-jdk directory of file checker.jar) use the -GPL2 license. - -Some external libraries that are included with the Checker Framework -distribution have different licenses. Here are some examples. - - * javaparser is dual licensed under the LGPL or the Apache license -- you - may use it under whichever one you want. (The javaparser source code - contains a file with the text of the GPL, but it is not clear why, since - javaparser does not use the GPL.) See - https://github.com/typetools/stubparser . - - * Annotation Tools (https://github.com/typetools/annotation-tools) uses - the MIT license. - - * Libraries in plume-lib (https://github.com/plume-lib/) are licensed - under the MIT License. - -=========================================================================== - -The GNU General Public License (GPL) - -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your freedom to share -and change it. By contrast, the GNU General Public License is intended to -guarantee your freedom to share and change free software--to make sure the -software is free for all its users. This General Public License applies to -most of the Free Software Foundation's software and to any other program whose -authors commit to using it. (Some other Free Software Foundation software is -covered by the GNU Library General Public License instead.) You can apply it to -your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom to -distribute copies of free software (and charge for this service if you wish), -that you receive source code or can get it if you want it, that you can change -the software or use pieces of it in new free programs; and that you know you -can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny -you these rights or to ask you to surrender the rights. These restrictions -translate to certain responsibilities for you if you distribute copies of the -software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for -a fee, you must give the recipients all the rights that you have. You must -make sure that they, too, receive or can get the source code. And you must -show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) -offer you this license which gives you legal permission to copy, distribute -and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that -everyone understands that there is no warranty for this free software. If the -software is modified by someone else and passed on, we want its recipients to -know that what they have is not the original, so that any problems introduced -by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We -wish to avoid the danger that redistributors of a free program will -individually obtain patent licenses, in effect making the program proprietary. -To prevent this, we have made it clear that any patent must be licensed for -everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification -follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice -placed by the copyright holder saying it may be distributed under the terms of -this General Public License. The "Program", below, refers to any such program -or work, and a "work based on the Program" means either the Program or any -derivative work under copyright law: that is to say, a work containing the -Program or a portion of it, either verbatim or with modifications and/or -translated into another language. (Hereinafter, translation is included -without limitation in the term "modification".) Each licensee is addressed as -"you". - -Activities other than copying, distribution and modification are not covered by -this License; they are outside its scope. The act of running the Program is -not restricted, and the output from the Program is covered only if its contents -constitute a work based on the Program (independent of having been made by -running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as -you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this License -and to the absence of any warranty; and give any other recipients of the -Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may -at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus -forming a work based on the Program, and copy and distribute such modifications -or work under the terms of Section 1 above, provided that you also meet all of -these conditions: - - a) You must cause the modified files to carry prominent notices stating - that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in whole or - in part contains or is derived from the Program or any part thereof, to be - licensed as a whole at no charge to all third parties under the terms of - this License. - - c) If the modified program normally reads commands interactively when run, - you must cause it, when started running for such interactive use in the - most ordinary way, to print or display an announcement including an - appropriate copyright notice and a notice that there is no warranty (or - else, saying that you provide a warranty) and that users may redistribute - the program under these conditions, and telling the user how to view a copy - of this License. (Exception: if the Program itself is interactive but does - not normally print such an announcement, your work based on the Program is - not required to print an announcement.) - -These requirements apply to the modified work as a whole. If identifiable -sections of that work are not derived from the Program, and can be reasonably -considered independent and separate works in themselves, then this License, and -its terms, do not apply to those sections when you distribute them as separate -works. But when you distribute the same sections as part of a whole which is a -work based on the Program, the distribution of the whole must be on the terms -of this License, whose permissions for other licensees extend to the entire -whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your -rights to work written entirely by you; rather, the intent is to exercise the -right to control the distribution of derivative or collective works based on -the Program. - -In addition, mere aggregation of another work not based on the Program with the -Program (or with a work based on the Program) on a volume of a storage or -distribution medium does not bring the other work under the scope of this -License. - -3. You may copy and distribute the Program (or a work based on it, under -Section 2) in object code or executable form under the terms of Sections 1 and -2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable source - code, which must be distributed under the terms of Sections 1 and 2 above - on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three years, to - give any third party, for a charge no more than your cost of physically - performing source distribution, a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of Sections 1 - and 2 above on a medium customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer to - distribute corresponding source code. (This alternative is allowed only - for noncommercial distribution and only if you received the program in - object code or executable form with such an offer, in accord with - Subsection b above.) - -The source code for a work means the preferred form of the work for making -modifications to it. For an executable work, complete source code means all -the source code for all modules it contains, plus any associated interface -definition files, plus the scripts used to control compilation and installation -of the executable. However, as a special exception, the source code -distributed need not include anything that is normally distributed (in either -source or binary form) with the major components (compiler, kernel, and so on) -of the operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the source -code from the same place counts as distribution of the source code, even though -third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as -expressly provided under this License. Any attempt otherwise to copy, modify, -sublicense or distribute the Program is void, and will automatically terminate -your rights under this License. However, parties who have received copies, or -rights, from you under this License will not have their licenses terminated so -long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. -However, nothing else grants you permission to modify or distribute the Program -or its derivative works. These actions are prohibited by law if you do not -accept this License. Therefore, by modifying or distributing the Program (or -any work based on the Program), you indicate your acceptance of this License to -do so, and all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), -the recipient automatically receives a license from the original licensor to -copy, distribute or modify the Program subject to these terms and conditions. -You may not impose any further restrictions on the recipients' exercise of the -rights granted herein. You are not responsible for enforcing compliance by -third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), conditions -are imposed on you (whether by court order, agreement or otherwise) that -contradict the conditions of this License, they do not excuse you from the -conditions of this License. If you cannot distribute so as to satisfy -simultaneously your obligations under this License and any other pertinent -obligations, then as a consequence you may not distribute the Program at all. -For example, if a patent license would not permit royalty-free redistribution -of the Program by all those who receive copies directly or indirectly through -you, then the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply and -the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or -other property right claims or to contest validity of any such claims; this -section has the sole purpose of protecting the integrity of the free software -distribution system, which is implemented by public license practices. Many -people have made generous contributions to the wide range of software -distributed through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing to -distribute software through any other system and a licensee cannot impose that -choice. - -This section is intended to make thoroughly clear what is believed to be a -consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain -countries either by patents or by copyrighted interfaces, the original -copyright holder who places the Program under this License may add an explicit -geographical distribution limitation excluding those countries, so that -distribution is permitted only in or among countries not thus excluded. In -such case, this License incorporates the limitation as if written in the body -of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the -General Public License from time to time. Such new versions will be similar in -spirit to the present version, but may differ in detail to address new problems -or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any later -version", you have the option of following the terms and conditions either of -that version or of any later version published by the Free Software Foundation. -If the Program does not specify a version number of this License, you may -choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs -whose distribution conditions are different, write to the author to ask for -permission. For software which is copyrighted by the Free Software Foundation, -write to the Free Software Foundation; we sometimes make exceptions for this. -Our decision will be guided by the two goals of preserving the free status of -all derivatives of our free software and of promoting the sharing and reuse of -software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR -THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE -STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE -PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, -YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE -PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR -INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA -BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER -OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible -use to the public, the best way to achieve this is to make it free software -which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach -them to the start of each source file to most effectively convey the exclusion -of warranty; and each file should have at least the "copyright" line and a -pointer to where the full notice is found. - - One line to give the program's name and a brief idea of what it does. - - Copyright (C) - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this when it -starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author Gnomovision comes - with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free - software, and you are welcome to redistribute it under certain conditions; - type 'show c' for details. - -The hypothetical commands 'show w' and 'show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may be -called something other than 'show w' and 'show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your school, -if any, to sign a "copyright disclaimer" for the program, if necessary. Here -is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - 'Gnomovision' (which makes passes at compilers) written by James Hacker. - - signature of Ty Coon, 1 April 1989 - - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General Public -License instead of this License. - - -"CLASSPATH" EXCEPTION TO THE GPL - -Certain source files distributed by Oracle America and/or its affiliates are -subject to the following clarification and special exception to the GPL, but -only where Oracle has expressly included in the particular source file's header -the words "Oracle designates this particular file as subject to the "Classpath" -exception as provided by Oracle in the LICENSE file that accompanied this code." - - Linking this library statically or dynamically with other modules is making - a combined work based on this library. Thus, the terms and conditions of - the GNU General Public License cover the whole combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent modules, - and to copy and distribute the resulting executable under terms of your - choice, provided that you also meet, for each linked independent module, - the terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. If - you modify this library, you may extend this exception to your version of - the library, but you are not obligated to do so. If you do not wish to do - so, delete this exception statement from your version. - -=========================================================================== - -MIT License: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -=========================================================================== diff --git a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/NOTICES b/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/NOTICES deleted file mode 100644 index 2f40bf232f12..000000000000 --- a/distribution/engine/THIRD-PARTY/org.checkerframework.checker-qual-3.33.0/NOTICES +++ /dev/null @@ -1,5 +0,0 @@ -This program only distributes portions of the module contained in one of the checker-qual*.jar files, -so as described in the attached LICENSE.txt, only the MIT license applies. -The LGPL license is included for completeness, but it does not apply in our usecase, -as we only distribute the MIT-licensed components. - diff --git a/tools/legal-review/engine/com.google.errorprone.error_prone_annotations-2.18.0/copyright-keep b/tools/legal-review/engine/com.google.errorprone.error_prone_annotations-2.18.0/copyright-keep deleted file mode 100644 index e234df55170b..000000000000 --- a/tools/legal-review/engine/com.google.errorprone.error_prone_annotations-2.18.0/copyright-keep +++ /dev/null @@ -1,5 +0,0 @@ -Copyright 2014 The Error Prone Authors. -Copyright 2015 The Error Prone Authors. -Copyright 2016 The Error Prone Authors. -Copyright 2017 The Error Prone Authors. -Copyright 2021 The Error Prone Authors. diff --git a/tools/legal-review/engine/com.google.guava.failureaccess-1.0.1/copyright-keep-context b/tools/legal-review/engine/com.google.guava.failureaccess-1.0.1/copyright-keep-context deleted file mode 100644 index 78171f905f2f..000000000000 --- a/tools/legal-review/engine/com.google.guava.failureaccess-1.0.1/copyright-keep-context +++ /dev/null @@ -1 +0,0 @@ -Copyright (C) 2018 The Guava Authors diff --git a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-ignore b/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-ignore deleted file mode 100644 index ea2f7d507fc5..000000000000 --- a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-ignore +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2005 The Guava Authors -Copyright (C) 2006 The Guava Authors -Copyright (C) 2007 The Guava Authors -Copyright (C) 2008 The Guava Authors -Copyright (C) 2009 The Guava Authors -Copyright (C) 2010 The Guava Authors -Copyright (C) 2011 The Guava Authors -Copyright (C) 2011 The Guava Authors. -Copyright (C) 2012 The Guava Authors -Copyright (C) 2013 The Guava Authors -Copyright (C) 2014 The Guava Authors -Copyright (C) 2015 The Guava Authors -Copyright (C) 2016 The Guava Authors -Copyright (C) 2017 The Guava Authors -Copyright (C) 2018 The Guava Authors -Copyright (C) 2019 The Guava Authors -Copyright (C) 2020 The Guava Authors -Copyright 2019 The Guava Authors -hereby disclaims copyright to this source code. diff --git a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-keep b/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-keep deleted file mode 100644 index fba50dc4b352..000000000000 --- a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/copyright-keep +++ /dev/null @@ -1,3 +0,0 @@ -Copyright (C) 2021 The Guava Authors -Copyright 2011 Google Inc. All Rights Reserved. -domain. The author hereby disclaims copyright to this source code. diff --git a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/files-ignore b/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/files-ignore deleted file mode 100644 index b9005a4d5ae7..000000000000 --- a/tools/legal-review/engine/com.google.guava.guava-32.0.0-jre/files-ignore +++ /dev/null @@ -1 +0,0 @@ -META-INF/LICENSE diff --git a/tools/legal-review/engine/com.google.j2objc.j2objc-annotations-2.8/copyright-keep b/tools/legal-review/engine/com.google.j2objc.j2objc-annotations-2.8/copyright-keep deleted file mode 100644 index 0b517a543509..000000000000 --- a/tools/legal-review/engine/com.google.j2objc.j2objc-annotations-2.8/copyright-keep +++ /dev/null @@ -1 +0,0 @@ -Copyright 2012 Google Inc. All Rights Reserved. diff --git a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/copyright-add b/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/copyright-add deleted file mode 100644 index a4b7bb99c547..000000000000 --- a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/copyright-add +++ /dev/null @@ -1,4 +0,0 @@ -This program only distributes portions of the module contained in one of the checker-qual*.jar files, -so as described in the attached LICENSE.txt, only the MIT license applies. -The LGPL license is included for completeness, but it does not apply in our usecase, -as we only distribute the MIT-licensed components. diff --git a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/custom-license b/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/custom-license deleted file mode 100644 index 35252fda76e8..000000000000 --- a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/custom-license +++ /dev/null @@ -1 +0,0 @@ -LICENSE.txt diff --git a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-add/LICENSE.txt b/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-add/LICENSE.txt deleted file mode 100644 index 70d6a70fe2fb..000000000000 --- a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-add/LICENSE.txt +++ /dev/null @@ -1,414 +0,0 @@ -The Checker Framework -Copyright 2004-present by the Checker Framework developers - - -Most of the Checker Framework is licensed under the GNU General Public -License, version 2 (GPL2), with the classpath exception. The text of this -license appears below. This is the same license used for OpenJDK. - -A few parts of the Checker Framework have more permissive licenses, notably -the parts that you might want to include with your own program. - - * The annotations and utility files are licensed under the MIT License. - (The text of this license also appears below.) This applies to the - checker-qual*.jar and all the files that appear in it: every file in a - qual/ directory, plus utility files FormatUtil.java, - I18nFormatUtil.java, NullnessUtil.java, Opt.java, PurityUnqualified.java, - RegexUtil.java, SignednessUtil.java, SignednessUtilExtra.java, and - UnitsTools.java. It also applies to the cleanroom implementations of - third-party annotations (in checker/src/testannotations/ and in - framework/src/main/java/org/jmlspecs/). - -The Checker Framework includes annotations for some libraries. Those in -.astub files use the MIT License. Those in https://github.com/typetools/jdk -(which appears in the annotated-jdk directory of file checker.jar) use the -GPL2 license. - -Some external libraries that are included with the Checker Framework -distribution have different licenses. Here are some examples. - - * javaparser is dual licensed under the LGPL or the Apache license -- you - may use it under whichever one you want. (The javaparser source code - contains a file with the text of the GPL, but it is not clear why, since - javaparser does not use the GPL.) See - https://github.com/typetools/stubparser . - - * Annotation Tools (https://github.com/typetools/annotation-tools) uses - the MIT license. - - * Libraries in plume-lib (https://github.com/plume-lib/) are licensed - under the MIT License. - -=========================================================================== - -The GNU General Public License (GPL) - -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your freedom to share -and change it. By contrast, the GNU General Public License is intended to -guarantee your freedom to share and change free software--to make sure the -software is free for all its users. This General Public License applies to -most of the Free Software Foundation's software and to any other program whose -authors commit to using it. (Some other Free Software Foundation software is -covered by the GNU Library General Public License instead.) You can apply it to -your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom to -distribute copies of free software (and charge for this service if you wish), -that you receive source code or can get it if you want it, that you can change -the software or use pieces of it in new free programs; and that you know you -can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny -you these rights or to ask you to surrender the rights. These restrictions -translate to certain responsibilities for you if you distribute copies of the -software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for -a fee, you must give the recipients all the rights that you have. You must -make sure that they, too, receive or can get the source code. And you must -show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) -offer you this license which gives you legal permission to copy, distribute -and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that -everyone understands that there is no warranty for this free software. If the -software is modified by someone else and passed on, we want its recipients to -know that what they have is not the original, so that any problems introduced -by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We -wish to avoid the danger that redistributors of a free program will -individually obtain patent licenses, in effect making the program proprietary. -To prevent this, we have made it clear that any patent must be licensed for -everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification -follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice -placed by the copyright holder saying it may be distributed under the terms of -this General Public License. The "Program", below, refers to any such program -or work, and a "work based on the Program" means either the Program or any -derivative work under copyright law: that is to say, a work containing the -Program or a portion of it, either verbatim or with modifications and/or -translated into another language. (Hereinafter, translation is included -without limitation in the term "modification".) Each licensee is addressed as -"you". - -Activities other than copying, distribution and modification are not covered by -this License; they are outside its scope. The act of running the Program is -not restricted, and the output from the Program is covered only if its contents -constitute a work based on the Program (independent of having been made by -running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as -you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this License -and to the absence of any warranty; and give any other recipients of the -Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may -at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus -forming a work based on the Program, and copy and distribute such modifications -or work under the terms of Section 1 above, provided that you also meet all of -these conditions: - - a) You must cause the modified files to carry prominent notices stating - that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in whole or - in part contains or is derived from the Program or any part thereof, to be - licensed as a whole at no charge to all third parties under the terms of - this License. - - c) If the modified program normally reads commands interactively when run, - you must cause it, when started running for such interactive use in the - most ordinary way, to print or display an announcement including an - appropriate copyright notice and a notice that there is no warranty (or - else, saying that you provide a warranty) and that users may redistribute - the program under these conditions, and telling the user how to view a copy - of this License. (Exception: if the Program itself is interactive but does - not normally print such an announcement, your work based on the Program is - not required to print an announcement.) - -These requirements apply to the modified work as a whole. If identifiable -sections of that work are not derived from the Program, and can be reasonably -considered independent and separate works in themselves, then this License, and -its terms, do not apply to those sections when you distribute them as separate -works. But when you distribute the same sections as part of a whole which is a -work based on the Program, the distribution of the whole must be on the terms -of this License, whose permissions for other licensees extend to the entire -whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your -rights to work written entirely by you; rather, the intent is to exercise the -right to control the distribution of derivative or collective works based on -the Program. - -In addition, mere aggregation of another work not based on the Program with the -Program (or with a work based on the Program) on a volume of a storage or -distribution medium does not bring the other work under the scope of this -License. - -3. You may copy and distribute the Program (or a work based on it, under -Section 2) in object code or executable form under the terms of Sections 1 and -2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable source - code, which must be distributed under the terms of Sections 1 and 2 above - on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three years, to - give any third party, for a charge no more than your cost of physically - performing source distribution, a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of Sections 1 - and 2 above on a medium customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer to - distribute corresponding source code. (This alternative is allowed only - for noncommercial distribution and only if you received the program in - object code or executable form with such an offer, in accord with - Subsection b above.) - -The source code for a work means the preferred form of the work for making -modifications to it. For an executable work, complete source code means all -the source code for all modules it contains, plus any associated interface -definition files, plus the scripts used to control compilation and installation -of the executable. However, as a special exception, the source code -distributed need not include anything that is normally distributed (in either -source or binary form) with the major components (compiler, kernel, and so on) -of the operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the source -code from the same place counts as distribution of the source code, even though -third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as -expressly provided under this License. Any attempt otherwise to copy, modify, -sublicense or distribute the Program is void, and will automatically terminate -your rights under this License. However, parties who have received copies, or -rights, from you under this License will not have their licenses terminated so -long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. -However, nothing else grants you permission to modify or distribute the Program -or its derivative works. These actions are prohibited by law if you do not -accept this License. Therefore, by modifying or distributing the Program (or -any work based on the Program), you indicate your acceptance of this License to -do so, and all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), -the recipient automatically receives a license from the original licensor to -copy, distribute or modify the Program subject to these terms and conditions. -You may not impose any further restrictions on the recipients' exercise of the -rights granted herein. You are not responsible for enforcing compliance by -third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), conditions -are imposed on you (whether by court order, agreement or otherwise) that -contradict the conditions of this License, they do not excuse you from the -conditions of this License. If you cannot distribute so as to satisfy -simultaneously your obligations under this License and any other pertinent -obligations, then as a consequence you may not distribute the Program at all. -For example, if a patent license would not permit royalty-free redistribution -of the Program by all those who receive copies directly or indirectly through -you, then the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply and -the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or -other property right claims or to contest validity of any such claims; this -section has the sole purpose of protecting the integrity of the free software -distribution system, which is implemented by public license practices. Many -people have made generous contributions to the wide range of software -distributed through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing to -distribute software through any other system and a licensee cannot impose that -choice. - -This section is intended to make thoroughly clear what is believed to be a -consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain -countries either by patents or by copyrighted interfaces, the original -copyright holder who places the Program under this License may add an explicit -geographical distribution limitation excluding those countries, so that -distribution is permitted only in or among countries not thus excluded. In -such case, this License incorporates the limitation as if written in the body -of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the -General Public License from time to time. Such new versions will be similar in -spirit to the present version, but may differ in detail to address new problems -or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any later -version", you have the option of following the terms and conditions either of -that version or of any later version published by the Free Software Foundation. -If the Program does not specify a version number of this License, you may -choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs -whose distribution conditions are different, write to the author to ask for -permission. For software which is copyrighted by the Free Software Foundation, -write to the Free Software Foundation; we sometimes make exceptions for this. -Our decision will be guided by the two goals of preserving the free status of -all derivatives of our free software and of promoting the sharing and reuse of -software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR -THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE -STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE -PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, -YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE -PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR -INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA -BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER -OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible -use to the public, the best way to achieve this is to make it free software -which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach -them to the start of each source file to most effectively convey the exclusion -of warranty; and each file should have at least the "copyright" line and a -pointer to where the full notice is found. - - One line to give the program's name and a brief idea of what it does. - - Copyright (C) - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this when it -starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author Gnomovision comes - with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free - software, and you are welcome to redistribute it under certain conditions; - type 'show c' for details. - -The hypothetical commands 'show w' and 'show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may be -called something other than 'show w' and 'show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your school, -if any, to sign a "copyright disclaimer" for the program, if necessary. Here -is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - 'Gnomovision' (which makes passes at compilers) written by James Hacker. - - signature of Ty Coon, 1 April 1989 - - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General Public -License instead of this License. - - -"CLASSPATH" EXCEPTION TO THE GPL - -Certain source files distributed by Oracle America and/or its affiliates are -subject to the following clarification and special exception to the GPL, but -only where Oracle has expressly included in the particular source file's header -the words "Oracle designates this particular file as subject to the "Classpath" -exception as provided by Oracle in the LICENSE file that accompanied this code." - - Linking this library statically or dynamically with other modules is making - a combined work based on this library. Thus, the terms and conditions of - the GNU General Public License cover the whole combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent modules, - and to copy and distribute the resulting executable under terms of your - choice, provided that you also meet, for each linked independent module, - the terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. If - you modify this library, you may extend this exception to your version of - the library, but you are not obligated to do so. If you do not wish to do - so, delete this exception statement from your version. - -=========================================================================== - -MIT License: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -=========================================================================== diff --git a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-keep b/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-keep deleted file mode 100644 index 0256724c8d06..000000000000 --- a/tools/legal-review/engine/org.checkerframework.checker-qual-3.33.0/files-keep +++ /dev/null @@ -1 +0,0 @@ -META-INF/LICENSE.txt diff --git a/tools/legal-review/engine/report-state b/tools/legal-review/engine/report-state index 44e64adeb3af..9ae8126bf8db 100644 --- a/tools/legal-review/engine/report-state +++ b/tools/legal-review/engine/report-state @@ -1,3 +1,3 @@ -D0D1595E3558C5D3E4E1D040FFF078F2EE815059BA46F1BA0AF546A524303AC0 -3768984C1A9E71A22E77ED4EFEBA08B9A2BA4A8EB9220E5B206B67F9B58FDFDF +F97FB4D3980033CF50C4A0BFE96165C67BAABD39BB8F1802C704F93B425B9A28 +76B24D1E8F678DA196FA65B3D292B82789F2CE19ADCEE20F8F233E82033328BC 0 From c5f03b01d4ccc6f32a213d3973976cd3c8ba6e05 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 08:03:42 +0200 Subject: [PATCH 13/19] ./runner --run test/Base_Tests/ ^Text succeeds --- build/build/src/engine/context.rs | 2 +- .../lib/Standard/Base/0.0.0-dev/src/Data/Json.enso | 3 ++- .../Standard/Base/0.0.0-dev/src/Data/Ordering.enso | 4 ++++ .../Standard/Base/0.0.0-dev/src/Data/Statistics.enso | 11 ++++++----- .../Base/0.0.0-dev/src/Data/Text/Extensions.enso | 7 ++++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 63e6523410f7..1f024b7b8297 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -650,7 +650,7 @@ pub async fn runner_sanity_test( "Native runner output does not contain expected result '{factorial_expected_output}'. Output:\n{output}", ); let test_base = Command::new(&repo_root.runner) - .args(["--run", repo_root.test.join("Base_Tests").as_str(), "Test\\."]) + .args(["--run", repo_root.test.join("Base_Tests").as_str(), "^Text"]) .set_env_opt(ENSO_JAVA, enso_java)? .set_env(ENSO_DATA_DIRECTORY, engine_package)? .run_stdout() diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso index f384a3a1e723..4180b173102e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso @@ -42,6 +42,7 @@ polyglot java import com.fasterxml.jackson.databind.node.NullNode polyglot java import com.fasterxml.jackson.databind.node.ObjectNode polyglot java import com.fasterxml.jackson.databind.node.TextNode polyglot java import com.fasterxml.jackson.databind.ObjectMapper +polyglot java import java.util.Iterator ## Methods for serializing from and to JSON. type Json @@ -151,7 +152,7 @@ type JS_Object Vector.build initial_capacity=object.size builder-> loop iterator builder = if iterator.hasNext then - builder.append iterator.next + builder.append (iterator:Iterator).next @Tail_Call loop iterator builder loop name_iterator builder JS_Object.Value object_node (make_field_names object_node) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index 052a2f8ced73..0b8b4fc82f41 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -12,6 +12,10 @@ import project.Nothing.Nothing import project.Panic.Panic from project.Data.Boolean import Boolean, False, True +# needed by Comparator_Spec: +polyglot java import org.enso.base.ObjectComparator +polyglot java import org.enso.base.CompareException + ## Provides custom ordering, equality check and hash code for types that need it. The Enso runtime system offers default implementation of _equality_ diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso index 5806b4568606..4d021375942c 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso @@ -23,6 +23,7 @@ polyglot java import java.lang.NullPointerException polyglot java import org.enso.base.CompareException polyglot java import org.enso.base.statistics.CorrelationStatistics polyglot java import org.enso.base.statistics.Rank +polyglot java import org.enso.base.statistics.Rank.Method polyglot java import org.enso.base.statistics.Statistic as Java_Statistic ## Specifies how to handle ranking of equal values. @@ -52,11 +53,11 @@ type Rank_Method compute : Vector -> Vector compute self input = java_method = case self of - Rank_Method.Minimum -> Rank.Method.MINIMUM - Rank_Method.Maximum -> Rank.Method.MAXIMUM - Rank_Method.Average -> Rank.Method.AVERAGE - Rank_Method.Ordinal -> Rank.Method.ORDINAL - Rank_Method.Dense -> Rank.Method.DENSE + Rank_Method.Minimum -> Method.MINIMUM + Rank_Method.Maximum -> Method.MAXIMUM + Rank_Method.Average -> Method.AVERAGE + Rank_Method.Ordinal -> Method.ORDINAL + Rank_Method.Dense -> Method.DENSE report_nullpointer caught_panic = Error.throw (Illegal_Argument.Error caught_panic.payload.getMessage) handle_nullpointer = Panic.catch NullPointerException handler=report_nullpointer diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index 0dab00afa906..bf97d8347fe4 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -47,6 +47,11 @@ polyglot java import org.enso.base.Regex_Utils polyglot java import org.enso.base.Text_Utils polyglot java import org.enso.base.text.Utf16Span polyglot java import org.enso.base.text.GraphemeSpan +polyglot java import org.enso.base.text.ResultWithWarnings + +# needed by Util_Spec +polyglot java import org.enso.base.text.CaseFoldedString +polyglot java import org.enso.base.text.CaseFoldedString.Grapheme ## GROUP Text ICON text @@ -726,7 +731,7 @@ Text.bytes self encoding on_problems=Problem_Behavior.Report_Warning = @encoding Encoding.default_widget Text.from_bytes : Vector Integer -> Encoding -> Problem_Behavior -> Text Text.from_bytes bytes encoding on_problems=Problem_Behavior.Report_Error = - result = Encoding_Utils.from_bytes bytes (encoding . to_java_charset) + result = Encoding_Utils.from_bytes bytes (encoding . to_java_charset) : ResultWithWarnings if result.warnings.is_nothing then result.result else on_problems.attach_problems_after result.result [Encoding_Error.Error result.warnings] From e08f7470373ac644eff2d62cfcf9abc38adb7cb1 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 09:37:00 +0200 Subject: [PATCH 14/19] Don't call safepoint() on Espresso, it is not needed --- .../java/org/enso/base/Encoding_Utils.java | 8 ++---- .../java/org/enso/base/Environment_Utils.java | 16 +++++++++++ .../java/org/enso/base/FileLineReader.java | 5 ++-- .../main/java/org/enso/base/Text_Utils.java | 27 +++++++------------ .../base/encoding/ReportingStreamEncoder.java | 6 ++--- .../statistics/CorrelationStatistics.java | 8 +++--- .../java/org/enso/base/statistics/Rank.java | 8 +++--- .../org/enso/base/text/CaseFoldedString.java | 8 +++--- 8 files changed, 40 insertions(+), 46 deletions(-) diff --git a/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java b/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java index 2bf3bfeab6e4..20867975db31 100644 --- a/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java @@ -18,7 +18,6 @@ import org.enso.base.encoding.ReportingStreamDecoder; import org.enso.base.encoding.ReportingStreamEncoder; import org.enso.base.text.ResultWithWarnings; -import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; public class Encoding_Utils { @@ -47,7 +46,6 @@ public static ResultWithWarnings get_bytes(String str, Charset charset) CharBuffer in = CharBuffer.wrap(str.toCharArray()); ByteBuffer out = ByteBuffer.allocate((int) (in.remaining() * encoder.averageBytesPerChar())); - Context context = Context.getCurrent(); StringBuilder warnings = null; while (in.hasRemaining()) { CoderResult cr = encoder.encode(in, out, true); @@ -78,7 +76,7 @@ public static ResultWithWarnings get_bytes(String str, Charset charset) out = resize(out, ByteBuffer::allocate, ByteBuffer::put); } - context.safepoint(); + Environment_Utils.safepoint(); } out.flip(); @@ -107,8 +105,6 @@ public static ResultWithWarnings from_bytes(byte[] bytes, Charset charse return new ResultWithWarnings<>(""); } - Context context = Context.getCurrent(); - CharsetDecoder decoder = charset .newDecoder() @@ -149,7 +145,7 @@ public static ResultWithWarnings from_bytes(byte[] bytes, Charset charse out = resize(out, CharBuffer::allocate, CharBuffer::put); } - context.safepoint(); + Environment_Utils.safepoint(); } out.flip(); diff --git a/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java b/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java index 8e90645c0e9f..e4a0cdce6957 100644 --- a/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java @@ -1,8 +1,24 @@ package org.enso.base; import java.util.HashMap; +import org.graalvm.polyglot.Context; public class Environment_Utils { + private static final boolean isEspresso; + + static { + var name = System.getProperty("java.vm.name"); + isEspresso = name != null && name.startsWith("Espresso"); + } + + private Environment_Utils() {} + + public static void safepoint() { + if (!isEspresso) { + Context.getCurrent().safepoint(); + } + } + /** Gets the environment variable, including any overrides. */ public static String get_environment_variable(String name) { String override = overrides.get(name); diff --git a/std-bits/base/src/main/java/org/enso/base/FileLineReader.java b/std-bits/base/src/main/java/org/enso/base/FileLineReader.java index 3cdc32a833d7..773366f75d81 100644 --- a/std-bits/base/src/main/java/org/enso/base/FileLineReader.java +++ b/std-bits/base/src/main/java/org/enso/base/FileLineReader.java @@ -16,7 +16,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.enso.base.arrays.LongArrayList; -import org.graalvm.polyglot.Context; /** A reader for reading lines from a file one at a time. */ public class FileLineReader { @@ -132,7 +131,7 @@ private static boolean readLine(MappedByteBuffer buffer, ByteArrayOutputStream r while (moreToRead(c, buffer)) { result.write(c); c = readByte(buffer); - Context.getCurrent().safepoint(); + Environment_Utils.safepoint(); } return c != -1 && (c != '\r' || buffer.hasRemaining()); } @@ -145,7 +144,7 @@ private static boolean scanLine(MappedByteBuffer buffer) { int c = readByte(buffer); while (moreToRead(c, buffer)) { c = readByte(buffer); - Context.getCurrent().safepoint(); + Environment_Utils.safepoint(); } return c != -1 && (c != '\r' || buffer.hasRemaining()); } diff --git a/std-bits/base/src/main/java/org/enso/base/Text_Utils.java b/std-bits/base/src/main/java/org/enso/base/Text_Utils.java index b525ce753bf8..66e686167335 100644 --- a/std-bits/base/src/main/java/org/enso/base/Text_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Text_Utils.java @@ -17,7 +17,6 @@ import org.enso.base.text.GraphemeSpan; import org.enso.base.text.Utf16Span; import org.enso.polyglot.common_utils.Core_Text_Utils; -import org.graalvm.polyglot.Context; /** Utils for standard library operations on Text. */ public class Text_Utils { @@ -79,7 +78,6 @@ public static List split_on_lines(String str, boolean keep_endings) { int length = str.length(); int currentStart = 0; int currentPos = 0; - Context context = Context.getCurrent(); while (currentPos < length) { if (str.charAt(currentPos) == '\n') { acc.add(str.substring(currentStart, keep_endings ? currentPos + 1 : currentPos)); @@ -98,7 +96,7 @@ public static List split_on_lines(String str, boolean keep_endings) { currentPos += 1; } - context.safepoint(); + Environment_Utils.safepoint(); } if (currentStart < length) { @@ -356,10 +354,10 @@ public static List span_of_all(String haystack, String needle) { StringSearch search = new StringSearch(needle, haystack); ArrayList occurrences = new ArrayList<>(); int ix; - Context context = Context.getCurrent(); + System.err.println("Which Java: " + System.getProperties()); while ((ix = search.next()) != StringSearch.DONE) { occurrences.add(new Utf16Span(ix, ix + search.getMatchLength())); - context.safepoint(); + Environment_Utils.safepoint(); } return occurrences; } @@ -383,8 +381,6 @@ public static List span_of_all_multiple(String haystack, List .toArray(StringSearch[]::new); List occurrences = new ArrayList<>(); - Context context = Context.getCurrent(); - int ix = 0; while (ix != StringSearch.DONE) { int earliestIndex = -1; @@ -397,7 +393,7 @@ public static List span_of_all_multiple(String haystack, List earliestStart = start; } - context.safepoint(); + Environment_Utils.safepoint(); } if (earliestIndex == -1) { // No more matches. @@ -407,7 +403,7 @@ public static List span_of_all_multiple(String haystack, List occurrences.add(new Utf16Span(earliestStart, earliestStart + matchLength)); ix = earliestStart + matchLength; - context.safepoint(); + Environment_Utils.safepoint(); } return occurrences; @@ -431,11 +427,10 @@ public static long utf16_index_to_grapheme_index(String text, long codeunit_inde int grapheme_end = breakIterator.next(); long grapheme_index = 0; - Context context = Context.getCurrent(); while (grapheme_end <= codeunit_index && grapheme_end != BreakIterator.DONE) { grapheme_index++; grapheme_end = breakIterator.next(); - context.safepoint(); + Environment_Utils.safepoint(); } return grapheme_index; } @@ -464,13 +459,11 @@ public static long[] utf16_indices_to_grapheme_indices(String text, List c long[] result = new long[codeunit_indices.size()]; int result_ix = 0; - Context context = Context.getCurrent(); - for (long codeunit_index : codeunit_indices) { while (grapheme_end <= codeunit_index && grapheme_end != BreakIterator.DONE) { grapheme_index++; grapheme_end = breakIterator.next(); - context.safepoint(); + Environment_Utils.safepoint(); } result[result_ix++] = grapheme_index; } @@ -534,10 +527,9 @@ public static List span_of_all_case_insensitive( ArrayList result = new ArrayList<>(); int pos; - Context context = Context.getCurrent(); while ((pos = search.next()) != StringSearch.DONE) { result.add(findExtendedSpan(foldedHaystack, pos, search.getMatchLength())); - context.safepoint(); + Environment_Utils.safepoint(); } return result; @@ -659,7 +651,6 @@ public static boolean is_all_letters(String text) { */ public static String replace_spans(String str, List spans, String newSequence) { StringBuilder sb = new StringBuilder(); - Context context = Context.getCurrent(); int current_ix = 0; for (Utf16Span span : spans) { if (span.codeunit_start > current_ix) { @@ -668,7 +659,7 @@ public static String replace_spans(String str, List spans, String new sb.append(newSequence); current_ix = span.codeunit_end; - context.safepoint(); + Environment_Utils.safepoint(); } // Add the remaining part of the string (if any). diff --git a/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java b/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java index 01cc351730f5..61b6385743d2 100644 --- a/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java +++ b/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.stream.Collectors; import org.enso.base.Encoding_Utils; -import org.graalvm.polyglot.Context; +import org.enso.base.Environment_Utils; /** * A {@code Writer} which encodes any characters provided to itself using the provided {@code @@ -113,8 +113,6 @@ public void write(char[] cbuf, int off, int len) throws IOException { } private void runEncoderOnInputBuffer() { - Context context = Context.getCurrent(); - while (inputBuffer.hasRemaining()) { CoderResult cr = encoder.encode(inputBuffer, outputBuffer, false); @@ -133,7 +131,7 @@ private void runEncoderOnInputBuffer() { growOutputBuffer(); } - context.safepoint(); + Environment_Utils.safepoint(); } } diff --git a/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java b/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java index 95433cdef7db..7397fb8559db 100644 --- a/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java +++ b/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java @@ -1,6 +1,6 @@ package org.enso.base.statistics; -import org.graalvm.polyglot.Context; +import org.enso.base.Environment_Utils; /** Class to compute covariance and correlations between series. */ public class CorrelationStatistics { @@ -120,7 +120,6 @@ public static CorrelationStatistics compute(Double[] x, Double[] y) { public static CorrelationStatistics[][] computeMatrix(Double[][] data) { int len = data[0].length; - Context context = Context.getCurrent(); CorrelationStatistics[][] output = new CorrelationStatistics[data.length][]; for (int i = 0; i < data.length; i++) { if (data[i].length != len) { @@ -134,7 +133,7 @@ public static CorrelationStatistics[][] computeMatrix(Double[][] data) { output[i][j] = compute(data[i], data[j]); } - context.safepoint(); + Environment_Utils.safepoint(); } } return output; @@ -143,11 +142,10 @@ public static CorrelationStatistics[][] computeMatrix(Double[][] data) { public static double spearmanRankCorrelation(Double[] x, Double[] y) { double[][] pairedRanks = Rank.pairedRanks(x, y, Rank.Method.AVERAGE); - Context context = Context.getCurrent(); CorrelationStatistics computation = new CorrelationStatistics(); for (int i = 0; i < pairedRanks[0].length; i++) { computation.append(pairedRanks[0][i], pairedRanks[1][i]); - context.safepoint(); + Environment_Utils.safepoint(); } return computation.pearsonCorrelation(); } diff --git a/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java b/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java index e6fee361f869..a90626c20e76 100644 --- a/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java +++ b/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import org.enso.base.Environment_Utils; import org.enso.base.ObjectComparator; -import org.graalvm.polyglot.Context; public class Rank { private static final Comparator DOUBLE_COMPARATOR = @@ -39,7 +39,6 @@ public static double[][] pairedRanks(Double[] x, Double[] y, Method method) throw new IllegalArgumentException("Left and right lengths are not the same."); } - Context context = Context.getCurrent(); List x_tuples = new ArrayList<>(x.length); List y_tuples = new ArrayList<>(y.length); for (int i = 0; i < x.length; i++) { @@ -50,7 +49,7 @@ public static double[][] pairedRanks(Double[] x, Double[] y, Method method) x_tuples.add(new ValueWithIndex(x[i], x_tuples.size())); y_tuples.add(new ValueWithIndex(y[i], y_tuples.size())); - context.safepoint(); + Environment_Utils.safepoint(); } return new double[][] { @@ -71,7 +70,6 @@ private static double[] computeRankFromTuples( double[] output = new double[tuples.size()]; - Context context = Context.getCurrent(); int index = 0; int dense = 0; while (index < tuples.size()) { @@ -98,7 +96,7 @@ private static double[] computeRankFromTuples( output[tuples.get(i).index] = rank; } - context.safepoint(); + Environment_Utils.safepoint(); } return output; diff --git a/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java b/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java index abbd2b7f400e..ca6bf0b2f037 100644 --- a/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java +++ b/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java @@ -4,8 +4,8 @@ import com.ibm.icu.text.CaseMap; import com.ibm.icu.text.CaseMap.Fold; import java.util.Locale; +import org.enso.base.Environment_Utils; import org.enso.base.arrays.IntArrayBuilder; -import org.graalvm.polyglot.Context; /** * Represents a string transformed using Unicode Case Folding which can be used for case insensitive @@ -128,8 +128,6 @@ public static CaseFoldedString fold(CharSequence charSequence, Locale locale) { IntArrayBuilder codeunit_start_mapping = new IntArrayBuilder(charSequence.length() + 1); IntArrayBuilder codeunit_end_mapping = new IntArrayBuilder(charSequence.length() + 1); - Context context = Context.getCurrent(); - // We rely on the fact that ICU Case Folding is _not_ context-sensitive, i.e. the mapping of // each grapheme cluster is independent of surrounding ones. Regular casing is // context-sensitive. @@ -144,12 +142,12 @@ public static CaseFoldedString fold(CharSequence charSequence, Locale locale) { grapheme_mapping.add(grapheme_index); codeunit_start_mapping.add(current); codeunit_end_mapping.add(next); - context.safepoint(); + Environment_Utils.safepoint(); } grapheme_index++; current = next; - context.safepoint(); + Environment_Utils.safepoint(); } // The mapping should also be able to handle a {@code str.length()} query, so we add one more From 8d1d8af1efd9d561c31ee8dc22831dab77d3adde Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 09:37:34 +0200 Subject: [PATCH 15/19] Skip test/Base_Tests on Espresso, as we don't have regex engine right now --- build/build/src/engine/context.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 1f024b7b8297..eaa17546d2df 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -649,12 +649,17 @@ pub async fn runner_sanity_test( output.contains(factorial_expected_output), "Native runner output does not contain expected result '{factorial_expected_output}'. Output:\n{output}", ); - let test_base = Command::new(&repo_root.runner) - .args(["--run", repo_root.test.join("Base_Tests").as_str(), "^Text"]) - .set_env_opt(ENSO_JAVA, enso_java)? - .set_env(ENSO_DATA_DIRECTORY, engine_package)? - .run_stdout() - .await?; - ensure!(test_base.contains("0 tests failed."), "All tests shall succeed. Output:\n{test_base}",); + if enso_java.is_none() { + let test_base = Command::new(&repo_root.runner) + .args(["--run", repo_root.test.join("Base_Tests").as_str(), "^Text"]) + .set_env_opt(ENSO_JAVA, enso_java)? + .set_env(ENSO_DATA_DIRECTORY, engine_package)? + .run_stdout() + .await?; + ensure!( + test_base.contains("0 tests failed."), + "All tests shall succeed. Output:\n{test_base}", + ); + } Ok(()) } From 1be75e65bfb04c5c194f872a5114857b124e5bc2 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 11:19:19 +0200 Subject: [PATCH 16/19] Reverting Environment_Utils.safepoint() changes --- .../java/org/enso/base/Encoding_Utils.java | 8 ++++-- .../java/org/enso/base/Environment_Utils.java | 16 ----------- .../java/org/enso/base/FileLineReader.java | 5 ++-- .../main/java/org/enso/base/Text_Utils.java | 27 ++++++++++++------- .../base/encoding/ReportingStreamEncoder.java | 6 +++-- .../statistics/CorrelationStatistics.java | 8 +++--- .../java/org/enso/base/statistics/Rank.java | 8 +++--- .../org/enso/base/text/CaseFoldedString.java | 8 +++--- 8 files changed, 46 insertions(+), 40 deletions(-) diff --git a/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java b/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java index 20867975db31..2bf3bfeab6e4 100644 --- a/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Encoding_Utils.java @@ -18,6 +18,7 @@ import org.enso.base.encoding.ReportingStreamDecoder; import org.enso.base.encoding.ReportingStreamEncoder; import org.enso.base.text.ResultWithWarnings; +import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; public class Encoding_Utils { @@ -46,6 +47,7 @@ public static ResultWithWarnings get_bytes(String str, Charset charset) CharBuffer in = CharBuffer.wrap(str.toCharArray()); ByteBuffer out = ByteBuffer.allocate((int) (in.remaining() * encoder.averageBytesPerChar())); + Context context = Context.getCurrent(); StringBuilder warnings = null; while (in.hasRemaining()) { CoderResult cr = encoder.encode(in, out, true); @@ -76,7 +78,7 @@ public static ResultWithWarnings get_bytes(String str, Charset charset) out = resize(out, ByteBuffer::allocate, ByteBuffer::put); } - Environment_Utils.safepoint(); + context.safepoint(); } out.flip(); @@ -105,6 +107,8 @@ public static ResultWithWarnings from_bytes(byte[] bytes, Charset charse return new ResultWithWarnings<>(""); } + Context context = Context.getCurrent(); + CharsetDecoder decoder = charset .newDecoder() @@ -145,7 +149,7 @@ public static ResultWithWarnings from_bytes(byte[] bytes, Charset charse out = resize(out, CharBuffer::allocate, CharBuffer::put); } - Environment_Utils.safepoint(); + context.safepoint(); } out.flip(); diff --git a/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java b/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java index e4a0cdce6957..8e90645c0e9f 100644 --- a/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Environment_Utils.java @@ -1,24 +1,8 @@ package org.enso.base; import java.util.HashMap; -import org.graalvm.polyglot.Context; public class Environment_Utils { - private static final boolean isEspresso; - - static { - var name = System.getProperty("java.vm.name"); - isEspresso = name != null && name.startsWith("Espresso"); - } - - private Environment_Utils() {} - - public static void safepoint() { - if (!isEspresso) { - Context.getCurrent().safepoint(); - } - } - /** Gets the environment variable, including any overrides. */ public static String get_environment_variable(String name) { String override = overrides.get(name); diff --git a/std-bits/base/src/main/java/org/enso/base/FileLineReader.java b/std-bits/base/src/main/java/org/enso/base/FileLineReader.java index 773366f75d81..3cdc32a833d7 100644 --- a/std-bits/base/src/main/java/org/enso/base/FileLineReader.java +++ b/std-bits/base/src/main/java/org/enso/base/FileLineReader.java @@ -16,6 +16,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.enso.base.arrays.LongArrayList; +import org.graalvm.polyglot.Context; /** A reader for reading lines from a file one at a time. */ public class FileLineReader { @@ -131,7 +132,7 @@ private static boolean readLine(MappedByteBuffer buffer, ByteArrayOutputStream r while (moreToRead(c, buffer)) { result.write(c); c = readByte(buffer); - Environment_Utils.safepoint(); + Context.getCurrent().safepoint(); } return c != -1 && (c != '\r' || buffer.hasRemaining()); } @@ -144,7 +145,7 @@ private static boolean scanLine(MappedByteBuffer buffer) { int c = readByte(buffer); while (moreToRead(c, buffer)) { c = readByte(buffer); - Environment_Utils.safepoint(); + Context.getCurrent().safepoint(); } return c != -1 && (c != '\r' || buffer.hasRemaining()); } diff --git a/std-bits/base/src/main/java/org/enso/base/Text_Utils.java b/std-bits/base/src/main/java/org/enso/base/Text_Utils.java index 66e686167335..b525ce753bf8 100644 --- a/std-bits/base/src/main/java/org/enso/base/Text_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Text_Utils.java @@ -17,6 +17,7 @@ import org.enso.base.text.GraphemeSpan; import org.enso.base.text.Utf16Span; import org.enso.polyglot.common_utils.Core_Text_Utils; +import org.graalvm.polyglot.Context; /** Utils for standard library operations on Text. */ public class Text_Utils { @@ -78,6 +79,7 @@ public static List split_on_lines(String str, boolean keep_endings) { int length = str.length(); int currentStart = 0; int currentPos = 0; + Context context = Context.getCurrent(); while (currentPos < length) { if (str.charAt(currentPos) == '\n') { acc.add(str.substring(currentStart, keep_endings ? currentPos + 1 : currentPos)); @@ -96,7 +98,7 @@ public static List split_on_lines(String str, boolean keep_endings) { currentPos += 1; } - Environment_Utils.safepoint(); + context.safepoint(); } if (currentStart < length) { @@ -354,10 +356,10 @@ public static List span_of_all(String haystack, String needle) { StringSearch search = new StringSearch(needle, haystack); ArrayList occurrences = new ArrayList<>(); int ix; - System.err.println("Which Java: " + System.getProperties()); + Context context = Context.getCurrent(); while ((ix = search.next()) != StringSearch.DONE) { occurrences.add(new Utf16Span(ix, ix + search.getMatchLength())); - Environment_Utils.safepoint(); + context.safepoint(); } return occurrences; } @@ -381,6 +383,8 @@ public static List span_of_all_multiple(String haystack, List .toArray(StringSearch[]::new); List occurrences = new ArrayList<>(); + Context context = Context.getCurrent(); + int ix = 0; while (ix != StringSearch.DONE) { int earliestIndex = -1; @@ -393,7 +397,7 @@ public static List span_of_all_multiple(String haystack, List earliestStart = start; } - Environment_Utils.safepoint(); + context.safepoint(); } if (earliestIndex == -1) { // No more matches. @@ -403,7 +407,7 @@ public static List span_of_all_multiple(String haystack, List occurrences.add(new Utf16Span(earliestStart, earliestStart + matchLength)); ix = earliestStart + matchLength; - Environment_Utils.safepoint(); + context.safepoint(); } return occurrences; @@ -427,10 +431,11 @@ public static long utf16_index_to_grapheme_index(String text, long codeunit_inde int grapheme_end = breakIterator.next(); long grapheme_index = 0; + Context context = Context.getCurrent(); while (grapheme_end <= codeunit_index && grapheme_end != BreakIterator.DONE) { grapheme_index++; grapheme_end = breakIterator.next(); - Environment_Utils.safepoint(); + context.safepoint(); } return grapheme_index; } @@ -459,11 +464,13 @@ public static long[] utf16_indices_to_grapheme_indices(String text, List c long[] result = new long[codeunit_indices.size()]; int result_ix = 0; + Context context = Context.getCurrent(); + for (long codeunit_index : codeunit_indices) { while (grapheme_end <= codeunit_index && grapheme_end != BreakIterator.DONE) { grapheme_index++; grapheme_end = breakIterator.next(); - Environment_Utils.safepoint(); + context.safepoint(); } result[result_ix++] = grapheme_index; } @@ -527,9 +534,10 @@ public static List span_of_all_case_insensitive( ArrayList result = new ArrayList<>(); int pos; + Context context = Context.getCurrent(); while ((pos = search.next()) != StringSearch.DONE) { result.add(findExtendedSpan(foldedHaystack, pos, search.getMatchLength())); - Environment_Utils.safepoint(); + context.safepoint(); } return result; @@ -651,6 +659,7 @@ public static boolean is_all_letters(String text) { */ public static String replace_spans(String str, List spans, String newSequence) { StringBuilder sb = new StringBuilder(); + Context context = Context.getCurrent(); int current_ix = 0; for (Utf16Span span : spans) { if (span.codeunit_start > current_ix) { @@ -659,7 +668,7 @@ public static String replace_spans(String str, List spans, String new sb.append(newSequence); current_ix = span.codeunit_end; - Environment_Utils.safepoint(); + context.safepoint(); } // Add the remaining part of the string (if any). diff --git a/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java b/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java index 61b6385743d2..01cc351730f5 100644 --- a/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java +++ b/std-bits/base/src/main/java/org/enso/base/encoding/ReportingStreamEncoder.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.stream.Collectors; import org.enso.base.Encoding_Utils; -import org.enso.base.Environment_Utils; +import org.graalvm.polyglot.Context; /** * A {@code Writer} which encodes any characters provided to itself using the provided {@code @@ -113,6 +113,8 @@ public void write(char[] cbuf, int off, int len) throws IOException { } private void runEncoderOnInputBuffer() { + Context context = Context.getCurrent(); + while (inputBuffer.hasRemaining()) { CoderResult cr = encoder.encode(inputBuffer, outputBuffer, false); @@ -131,7 +133,7 @@ private void runEncoderOnInputBuffer() { growOutputBuffer(); } - Environment_Utils.safepoint(); + context.safepoint(); } } diff --git a/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java b/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java index 7397fb8559db..95433cdef7db 100644 --- a/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java +++ b/std-bits/base/src/main/java/org/enso/base/statistics/CorrelationStatistics.java @@ -1,6 +1,6 @@ package org.enso.base.statistics; -import org.enso.base.Environment_Utils; +import org.graalvm.polyglot.Context; /** Class to compute covariance and correlations between series. */ public class CorrelationStatistics { @@ -120,6 +120,7 @@ public static CorrelationStatistics compute(Double[] x, Double[] y) { public static CorrelationStatistics[][] computeMatrix(Double[][] data) { int len = data[0].length; + Context context = Context.getCurrent(); CorrelationStatistics[][] output = new CorrelationStatistics[data.length][]; for (int i = 0; i < data.length; i++) { if (data[i].length != len) { @@ -133,7 +134,7 @@ public static CorrelationStatistics[][] computeMatrix(Double[][] data) { output[i][j] = compute(data[i], data[j]); } - Environment_Utils.safepoint(); + context.safepoint(); } } return output; @@ -142,10 +143,11 @@ public static CorrelationStatistics[][] computeMatrix(Double[][] data) { public static double spearmanRankCorrelation(Double[] x, Double[] y) { double[][] pairedRanks = Rank.pairedRanks(x, y, Rank.Method.AVERAGE); + Context context = Context.getCurrent(); CorrelationStatistics computation = new CorrelationStatistics(); for (int i = 0; i < pairedRanks[0].length; i++) { computation.append(pairedRanks[0][i], pairedRanks[1][i]); - Environment_Utils.safepoint(); + context.safepoint(); } return computation.pearsonCorrelation(); } diff --git a/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java b/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java index a90626c20e76..e6fee361f869 100644 --- a/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java +++ b/std-bits/base/src/main/java/org/enso/base/statistics/Rank.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import org.enso.base.Environment_Utils; import org.enso.base.ObjectComparator; +import org.graalvm.polyglot.Context; public class Rank { private static final Comparator DOUBLE_COMPARATOR = @@ -39,6 +39,7 @@ public static double[][] pairedRanks(Double[] x, Double[] y, Method method) throw new IllegalArgumentException("Left and right lengths are not the same."); } + Context context = Context.getCurrent(); List x_tuples = new ArrayList<>(x.length); List y_tuples = new ArrayList<>(y.length); for (int i = 0; i < x.length; i++) { @@ -49,7 +50,7 @@ public static double[][] pairedRanks(Double[] x, Double[] y, Method method) x_tuples.add(new ValueWithIndex(x[i], x_tuples.size())); y_tuples.add(new ValueWithIndex(y[i], y_tuples.size())); - Environment_Utils.safepoint(); + context.safepoint(); } return new double[][] { @@ -70,6 +71,7 @@ private static double[] computeRankFromTuples( double[] output = new double[tuples.size()]; + Context context = Context.getCurrent(); int index = 0; int dense = 0; while (index < tuples.size()) { @@ -96,7 +98,7 @@ private static double[] computeRankFromTuples( output[tuples.get(i).index] = rank; } - Environment_Utils.safepoint(); + context.safepoint(); } return output; diff --git a/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java b/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java index ca6bf0b2f037..abbd2b7f400e 100644 --- a/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java +++ b/std-bits/base/src/main/java/org/enso/base/text/CaseFoldedString.java @@ -4,8 +4,8 @@ import com.ibm.icu.text.CaseMap; import com.ibm.icu.text.CaseMap.Fold; import java.util.Locale; -import org.enso.base.Environment_Utils; import org.enso.base.arrays.IntArrayBuilder; +import org.graalvm.polyglot.Context; /** * Represents a string transformed using Unicode Case Folding which can be used for case insensitive @@ -128,6 +128,8 @@ public static CaseFoldedString fold(CharSequence charSequence, Locale locale) { IntArrayBuilder codeunit_start_mapping = new IntArrayBuilder(charSequence.length() + 1); IntArrayBuilder codeunit_end_mapping = new IntArrayBuilder(charSequence.length() + 1); + Context context = Context.getCurrent(); + // We rely on the fact that ICU Case Folding is _not_ context-sensitive, i.e. the mapping of // each grapheme cluster is independent of surrounding ones. Regular casing is // context-sensitive. @@ -142,12 +144,12 @@ public static CaseFoldedString fold(CharSequence charSequence, Locale locale) { grapheme_mapping.add(grapheme_index); codeunit_start_mapping.add(current); codeunit_end_mapping.add(next); - Environment_Utils.safepoint(); + context.safepoint(); } grapheme_index++; current = next; - Environment_Utils.safepoint(); + context.safepoint(); } // The mapping should also be able to handle a {@code str.length()} query, so we add one more From 5a1743ac52f2e89ed1e1a6521208916567f746a5 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 20 May 2024 20:17:38 +0200 Subject: [PATCH 17/19] Text - general group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Radosław Waśko --- test/Base_Tests/src/Data/Text_Spec.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Base_Tests/src/Data/Text_Spec.enso b/test/Base_Tests/src/Data/Text_Spec.enso index 3edbb8d30be5..3cc255207d7e 100644 --- a/test/Base_Tests/src/Data/Text_Spec.enso +++ b/test/Base_Tests/src/Data/Text_Spec.enso @@ -62,7 +62,7 @@ add_specs suite_builder = accent_1 = '\u00E9' accent_2 = '\u0065\u{301}' - suite_builder.group "Text.general" group_builder-> + suite_builder.group "Text - general" group_builder-> kshi = '\u0915\u094D\u0937\u093F' facepalm = '\u{1F926}\u{1F3FC}\u200D\u2642\uFE0F' utf_8_whitespace = 'foo\n bar baz \u202F quux' From 3db825ccb4c62f261cc0fdaf7581f1f136ee303d Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Tue, 21 May 2024 15:36:48 +0200 Subject: [PATCH 18/19] CompareException is imported by Statistics --- distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso | 1 - 1 file changed, 1 deletion(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index 0b8b4fc82f41..53633bd76eb7 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -14,7 +14,6 @@ from project.Data.Boolean import Boolean, False, True # needed by Comparator_Spec: polyglot java import org.enso.base.ObjectComparator -polyglot java import org.enso.base.CompareException ## Provides custom ordering, equality check and hash code for types that need it. From aaa5e9ec9ec39b510e977cfa67baa7f649b0d2c5 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 22 May 2024 13:14:56 +0200 Subject: [PATCH 19/19] Moving all extra polyglot java import into a single file --- .../Base/0.0.0-dev/src/Data/Ordering.enso | 3 --- .../Base/0.0.0-dev/src/Data/Text/Extensions.enso | 6 +----- .../lib/Standard/Base/0.0.0-dev/src/IO.enso | 3 --- .../0.0.0-dev/src/Internal/Extra_Imports.enso | 16 ++++++++++++++++ 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index dd3406e64ee4..bede1d9622d1 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -12,9 +12,6 @@ import project.Nothing.Nothing import project.Panic.Panic from project.Data.Boolean import Boolean, False, True -# needed by Comparator_Spec: -polyglot java import org.enso.base.ObjectComparator - ## Provides custom ordering, equality check and hash code for types that need it. The Enso runtime system offers default implementation of _equality_ diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index 8e48178f08b3..81a8ce41ef81 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -50,10 +50,6 @@ polyglot java import org.enso.base.text.Utf16Span polyglot java import org.enso.base.text.GraphemeSpan polyglot java import org.enso.base.text.ResultWithWarnings -# needed by Util_Spec -polyglot java import org.enso.base.text.CaseFoldedString -polyglot java import org.enso.base.text.CaseFoldedString.Grapheme - ## GROUP Text ICON text Returns a new `Text` object with the characters in the reverse order of the input. @@ -545,7 +541,7 @@ Text.replace self term:(Text | Regex) replacement:Text (case_sensitivity:Case_Se Applies the specified cleansings to the text. Arguments: - - remove: A vector of the text cleanings to remove from the text. The text cleansings are + - remove: A vector of the text cleanings to remove from the text. The text cleansings are applied in the order they are provided. The same text cleansing can be used multiple times. The text cleansings are: - ..Leading_Whitespace: Removes all whitspace from the start of the string. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso index 340cd1e0bbfe..900a61caf36e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/IO.enso @@ -2,9 +2,6 @@ import project.Any.Any import project.Data.Text.Text import project.Nothing.Nothing -# needed for Standard.Test.Test_Reporter -polyglot java import java.io.PrintStream - ## PRIVATE ADVANCED Prints the provided message to standard error. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso new file mode 100644 index 000000000000..4981b39243ae --- /dev/null +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso @@ -0,0 +1,16 @@ +private + +# this file contains additional imports necessary for +# building native image version of Enso with Standard +# libraries included in + +# needed for Standard.Test.Test_Reporter +# tracked as https://github.com/enso-org/enso/issues/10028 +polyglot java import java.io.PrintStream + +# needed by Util_Spec +polyglot java import org.enso.base.text.CaseFoldedString +polyglot java import org.enso.base.text.CaseFoldedString.Grapheme + +# needed by Comparator_Spec: +polyglot java import org.enso.base.ObjectComparator