Temporary Disabled. :) please Go back J2CL Now & Next · Issue #93 · google/j2cl · GitHub www.fgks.org » Address: [go: up one dir, main page] Include Form Remove Scripts Accept Cookies Show Images Show Referer Rotate13 Base64 Strip Meta Strip Title Session Cookies Skip to content Navigation Menu Toggle navigation Sign in Product Actions Automate any workflow Packages Host and manage packages Security Find and fix vulnerabilities Codespaces Instant dev environments GitHub Copilot Write better code with AI Code review Manage code changes Issues Plan and track work Discussions Collaborate outside of code Explore All features Documentation GitHub Skills Blog Solutions By size Enterprise Teams Startups By industry Healthcare Financial services Manufacturing By use case CI/CD & Automation DevOps DevSecOps Resources Topics AI DevOps Innersource Open Source Security Software Development Explore Learning Pathways White papers, Ebooks, Webinars Customer Stories Partners Open Source GitHub Sponsors Fund open source developers The ReadME Project GitHub community articles Repositories Topics Trending Collections Enterprise Enterprise platform AI-powered developer platform Available add-ons Advanced Security Enterprise-grade security features GitHub Copilot Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. Include my email address so I can be contacted Saved searches Use saved searches to filter your results more quickly Name Query To see all available qualifiers, see our documentation. Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} google / j2cl Public Notifications You must be signed in to change notification settings Fork 143 Star 1.2k Code Issues 25 Pull requests 6 Discussions Actions Security Insights Additional navigation options Code Issues Pull requests Discussions Actions Security Insights New issue Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Sign up for GitHub By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. Already on GitHub? Sign in to your account Jump to bottom J2CL Now & Next #93 Open 11 of 24 tasks gkdn opened this issue May 27, 2020 · 23 comments Open 11 of 24 tasks J2CL Now & Next #93 gkdn opened this issue May 27, 2020 · 23 comments Comments Copy link Member gkdn commented May 27, 2020 • edited Loading By popular request, I am listing the things that J2CL team is actively working on apart from continuous improvements and maintenance and what to expect in the next quarters: Last Edit: Jul 26, 2023 Now Modular compilation for Wasm Support Kotlin language Next Implement TestSuite support for Open Source Reduce limitations on @JsEnums Finalize supported Enum/EnumSet APIs Add periodic auto-tagging for Open Source for versioned releases Later Enable RTA pruning for Open Source development Investigate embedding GwtIncompatibleStripper step into J2CL Add ability to run JsInteropRestrictionChecker as an ErrorProne plugin Optimize Dagger to be more efficient with J2CL Switch default fronted from JDT to Javac Remove boxing from long (similar to double/Double) Support for Java 17 Completed in previous quarters [x ] Improve Wasm GC spec, tooling and J2CL experimental Wasm backend Implement testing support for Open Source Java 11 support (completed, waiting Bazel release) First-class support for JSR nullability Optimize AutoValue to be more efficient with J2CL Improve code generation Java enums to reduce code size Add experimental Wasm backend Switch to Bazel TreeArtifacts Overhaul bridge calculate&creation to fix related bugs and reduce code size Fix overflow for integer arithmetic Improve JsCompiler optimizations Switch to Bazelisk by default Note: The J2CL code is production ready and battle tested with Google Apps for years. Only open-source tooling is missing some workflows. All of our improvements to the released code are in sync with Google and you are getting the improvement at the same time as Google gets. At the moment for J2CL, we are only planning to do dated releases (instead of semantic versioning like v1) and make more tools work in open source over time. The text was updated successfully, but these errors were encountered: 👍 23 tbroyer, vegegoku, RobertoUa, yadavharsh, realityforge, FrankHossfeld, evanvelikanov, niloc132, NoamRabbani, pdfisk, and 13 more reacted with thumbs up emoji 🎉 1 RobertoMalatesta reacted with hooray emoji All reactions 👍 23 reactions 🎉 1 reaction gkdn pinned this issue May 27, 2020 This was referenced May 27, 2020 Roadmap or something like a release plan? #92 Closed ETA for v1 and meaning of "alpha" version #86 Closed Copy link rov63rus commented Sep 15, 2020 Are you planning gradle support ? Bazel is not known to any IDE. 👍 4 LifeIsStrange, FlyingYu-Z, thebabush, and mrpatrickpilch reacted with thumbs up emoji 👎 1 hsestupin reacted with thumbs down emoji ❤️ 1 LifeIsStrange reacted with heart emoji 🚀 2 LifeIsStrange and HJWAJ reacted with rocket emoji All reactions 👍 4 reactions 👎 1 reaction ❤️ 1 reaction 🚀 2 reactions Sorry, something went wrong. Copy link Contributor tbroyer commented Sep 15, 2020 https://docs.bazel.build/versions/master/ide.html ? (my main problem with the IntelliJ IDEA plugin though is that it's currently not compatible with latest IDEA 2020.2: bazelbuild/intellij#1998) All reactions Sorry, something went wrong. Copy link Contributor sgammon commented Dec 10, 2020 i would love to see some gRPC support on this list :) All reactions Sorry, something went wrong. Copy link Contributor treblereel commented Dec 23, 2020 Are there any workarounds how to run tests, before j2cl_test ll be ported ? It's a critical feature 👍 1 xamde reacted with thumbs up emoji All reactions 👍 1 reaction Sorry, something went wrong. Copy link rjahn commented Oct 15, 2021 any updates here? All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Oct 15, 2021 I update it every now and then but comment date doesn't reflect that (you need to click edited to see the change dates). 👍 2 tbroyer and treblereel reacted with thumbs up emoji All reactions 👍 2 reactions Sorry, something went wrong. Copy link LifeIsStrange commented Dec 2, 2021 Any update on Kotlin support? That would be amazing and java projects are increasingly hybridized with Kotlin All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Dec 14, 2021 We just started Kotlin work. Our goal is to have something usable by end of the year. 👍 1 LifeIsStrange reacted with thumbs up emoji ❤️ 1 LifeIsStrange reacted with heart emoji 🚀 1 LifeIsStrange reacted with rocket emoji All reactions 👍 1 reaction ❤️ 1 reaction 🚀 1 reaction Sorry, something went wrong. Copy link LifeIsStrange commented Dec 14, 2021 • edited Loading @gkdn that is amazing to hear but Kotlin JS is officially developed and has an excellent and mature support for transpiling Kotlin to JS (and generating typescript types) However while kotlin multiplarform/js is great, and while j2cl allow to transpile Java to js, I feel like the main area for improvement would be for J2CL to leverage existing Kotlin js transpiling ability and to be interoperable with the generated js from Java. If you could work on making it easier to have hybrid Kotlin-Java projects that target js that would be amazing, maybe that the biggest issue is about IDE supports at the boundaries (Kotlin js will not allow calling java code even if this java code transpile to J2CL). Improving this IDE interop between Java and Kotlin JS should be possible in theory, either by contributing directly to the Kotlin js compiler or by making a Kotlin compiler plugin (note that the replacement API for the new Kotlin compiler (K2) is in active development https://youtrack.jetbrains.com/issue/KT-49508 ) Also you might consider using arrow-meta which is a library that helps building compiler plugins. https://github.com/arrow-kt/arrow-meta BTW since you work at Google, maybe you could contact one of the official Google kotlin devs, as you can see here: https://kotlinlang.org/docs/kotlin-foundation.html#current-personnel for some guidance. The best would be to contact Roman Elizarov or to open a youtrack ticket for a collaboration :) I really hope there is the possibility of making a synergy with JetBrains! Anyway just my two cents on how to achieve the best of both worlds. BTW: I concur that Gradle support would be a step in the right direction for adoption. All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Dec 16, 2021 Our high demanding customers relies on very Closure style centric Google JavaScript stack (which J2CL is optimized for) and they count every single byte for performance. Unfortunately Kotlin/JS output doesn't match our needs and sometimes in a way that might be contradicting with the Kotlin open-source users needs who rely on different JavaScript stacks. So for now our main focus we will be enabling Kotlin to those customers. Being said that I already met with Roman on this and we are in contact with JetBreains. We will be still looking into bringing the two worlds together in the long run. All reactions Sorry, something went wrong. Copy link LifeIsStrange commented Dec 16, 2021 @gkdn I suppose you could apply a post processing step to the generated kotlin-js by feeding it to Closure. You could also work on improving the efficiency of the IR backend. But sure feel free to implement your own incompatible transpiler. All reactions Sorry, something went wrong. LifeIsStrange mentioned this issue Aug 23, 2022 Kotlin/JS codegen compiler extension JetBrains/kotlin#4925 Open Copy link Contributor treblereel commented Oct 22, 2022 @gkdn just in case, do you have any updates about testing support for Open Source ? All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Oct 25, 2022 We have an intern working on it at the moment but we will see how it will turn out. All reactions Sorry, something went wrong. Copy link Contributor treblereel commented Oct 25, 2022 We have an intern working on it at the moment but we will see how it will turn out. ok, and i suppose you have a deadline right ? All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Oct 25, 2022 Should be within 2 months; if the project is successful. 👍 1 treblereel reacted with thumbs up emoji All reactions 👍 1 reaction Sorry, something went wrong. Copy link Contributor treblereel commented Feb 2, 2023 Should be within 2 months; if the project is successful. It looks like it failed ... So pity :( All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Feb 4, 2023 • edited Loading Actually basic unit testing support is released, sample app and getting started code is updated accordingly. I haven't closed the task since it still doesn't support test suites but I will update the notes. Edit: updated 🚀 1 LifeIsStrange reacted with rocket emoji All reactions 🚀 1 reaction Sorry, something went wrong. Copy link Contributor treblereel commented Jan 31, 2024 @gkdn Do you plan to add support for the following methods from Java 9-11? Stream: takeWhile, dropWhile, ofNullable, and iterate String: isBlank, lines, repeat, strip, stripLeading, and stripTrailing List/Set/Map: copyOf Collectors: toUnmodifiable* And if not, can we make a PR? All reactions Sorry, something went wrong. Copy link Collaborator rluble commented Jan 31, 2024 We do accept contributions for missing jre methods. Note that the implementations need to : be supportable in the web (e.g. java.net.*, reflective apis, etc, are no supported, ). not impose onerous codesize increases (e.g. most functionality of Locale is not supported due to this). be created independently of existing implementations in other sdks. Isn't String.repeat is already in the JRE? 👍 1 treblereel reacted with thumbs up emoji All reactions 👍 1 reaction Sorry, something went wrong. Copy link Contributor niloc132 commented Feb 1, 2024 String.repeat is indeed already implemented - but can you direct us how to run its tests? (I assume tests are required for such submissions, even though it wasn't on your list ;). ) I see that jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java has a testRepeat method, but there don't seem to be any bazel targets to run individual test classes. #93 (comment) says (and seems to still be correct) that suites cannot run, and only jre/javatests/com/google/j2cl/jre/LangSuite.java references StringTest. Here's the other things I tried, just in case I missed the obvious: I noticed that LangSuite is referenced by the Lang j2cl_multi_test in jre/javatests/BUILD`, but running that results in $ bazel test //jre/javatests:Lang ERROR: Skipping '//jre/javatests:Lang': error loading package 'jre/javatests': Label '//javascript/tools/jscompiler/builddefs:flags.bzl' is invalid because 'javascript/tools/jscompiler/builddefs' is not a package; perhaps you meant to put the colon here: '//:javascript/tools/jscompiler/builddefs/flags.bzl'? ERROR: error loading package 'jre/javatests': Label '//javascript/tools/jscompiler/builddefs:flags.bzl' is invalid because 'javascript/tools/jscompiler/builddefs' is not a package; perhaps you meant to put the colon here: '//:javascript/tools/jscompiler/builddefs/flags.bzl'? INFO: Elapsed time: 0.207s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: jre/javatests Typically when we see //javascript labels, or references at all to jscompiler, it means that this isn't available to be run outside of Google. Removing that import line load("//javascript/tools/jscompiler/builddefs:flags.bzl", "VERBOSE_WARNING_FLAGS_STRICT", "WHITESPACE_ONLY_FLAGS") and all of the conformance test wiring that depends on it at least advances us to a new error: $ bazel test //jre/javatests:Lang ERROR: Skipping '//jre/javatests:Lang': error loading package 'jre/javatests': Label '//third_party/bazel_rules/rules_closure/closure:defs.bzl' is invalid because 'third_party/bazel_rules/rules_closure/closure' is not a package; perhaps you meant to put the colon here: '//third_party:bazel_rules/rules_closure/closure/defs.bzl'? ERROR: error loading package 'jre/javatests': Label '//third_party/bazel_rules/rules_closure/closure:defs.bzl' is invalid because 'third_party/bazel_rules/rules_closure/closure' is not a package; perhaps you meant to put the colon here: '//third_party:bazel_rules/rules_closure/closure/defs.bzl'? INFO: Elapsed time: 0.068s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: jre/javatests Fortunately this is also not terrible to fix: there are two separate load() calls for closure_js_binary - removing the second one still leaves the first (though to just run Lang, I've commented out both of them). Next, I was getting this error: $ bazel test //jre/javatests:Lang ERROR: Traceback (most recent call last): File "/home/colin/workspace/j2cl/jre/javatests/BUILD", line 85, column 16, in <toplevel> j2cl_multi_test( File "/home/colin/workspace/j2cl/jre/javatests/j2cl_multi_test.bzl", line 50, column 25, in j2cl_multi_test j2kt_native_test( File "/home/colin/workspace/j2cl/build_defs/internal_do_not_use/j2kt_test.bzl", line 16, column 21, in j2kt_native_test j2cl_test_common( File "/home/colin/workspace/j2cl/build_defs/internal_do_not_use/j2cl_test_common.bzl", line 274, column 13, in j2cl_test_common fail("Unknown platform: " + platform) Error in fail: Unknown platform: J2KT-NATIVE It looks like j2cl_multi_test itself isn't able to run in open source due to J2KT-NATIVE platform not being populated? The code only has branches for CLOSURE and WASM. Next I took the drastic step of removing all j2cl_multi_test (getting past the point of what I could comfortably suggest might even make sense to commit...), and instead wrote a custom test target: j2cl_test( name = "Lang", test_class = "com.google.j2cl.jre.LangSuite", runtime_deps = [":emul_tests_lib"], ) This hit compile errors, oddly - it seems that emul_tests_lib itself isn't set up properly? How can this run inside of Google at all? Or do you have entirely separate BUILD files (not just BUILD vs BUILD.bazel), and the checked in BUILD is never used? To fix, I changed my approach, not trying to run tests at all any more, but just get them to build, via bazel build //jre/javatests:emul_tests_lib. First I had to add //third_party:jspecify_annotations-j2cl to the deps list. Next, it seems that the list of disabled errorprone checks in emul_tests_lib is inconsistent with currently checked-in code - TreeMapTest.ConflictingKey either needs a SuppressWarnings on it, or a flag passed to errorprone - I opted for -Xep:ComparableType:OFF, as that seems to be the convention. At this point, emul_tests_lib can succeed in building. Next, I tried to build (not test) the modified Lang rule above - this failed with a confusing message: ERROR: /home/colin/workspace/j2cl/jre/javatests/BUILD:129:10: Executing genrule //jre/javatests:genLang_test.js failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument skipped) FAIL: j2cl_test currently supports testing with a single testsuite only. IF YOU HAVE MULTIPLE TESTSUITES, WE DO NOT KNOW IF ALL OF YOUR TESTS PASS OR NOT! Is it accurate to say that suites don't work, but a single suite would? Regardless, I changed my custom rule to only run StringTest: j2cl_test( name = "StringTest", test_class = "com.google.j2cl.jre.java.lang.StringTest", runtime_deps = [":emul_tests_lib"], ) This passed a bazel build finally, but tests fail (specifically testIndexOfNull). -> 02:03:46.792 : Running test: testIndexOfNull -> $module$exports$junit$framework$Assert$impl$m_fail__java_lang_String__void$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:1832:421 -> $testIndexOfNull$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4879:179 [native code] $invokeFunction_$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3869:42 $safeRunTest_$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3855:32 [native code] $goog$testing$TestCase$Continuation_$run$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4226:99 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3780:167 [native code] $goog$testing$TestCase$Continuation_$run$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4226:99 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3778:47 $goog$Promise$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:2631:32 $JSCompiler_StaticMethods_runTestsReturningPromise$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3777:22 $JSCompiler_StaticMethods_JSC$2497_execute$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:5582:159 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:5714:53 -> 02:03:46.793 : testIndexOfNull : FAILED Is there an easier way to go about running tests, so that we can migrate already-working java9-11 stream/optional/collection code into j2cl, complete with tests? Would any/all of this be suitable for a contribution, so that a CI script could exist that runs these emulation tests, in anticipation of emulation patches? All reactions Sorry, something went wrong. Copy link Member Author gkdn commented Feb 1, 2024 The JRE unit tests are not ported to open-source so they would not work out of the box. We are currently swamped with couple of a big projects but if you like to commit to the JRE emulation, the best I can offer at the moment is: Patch gkdn@9c7e780 Update StringTest in jre/javatests/BUILD with the class that you are testing. bazel test jre/javatests:StringTest to run the test bazel run jre/javatests:StringTest_debug and follow the link to run/debug on your browser. If you have further questions, let's start a discussion in the discussions section. All reactions Sorry, something went wrong. Copy link Contributor treblereel commented Feb 1, 2024 @gkdn Thanks a million; it works like a charm. All reactions Sorry, something went wrong. Copy link Contributor niloc132 commented Feb 1, 2024 Great, thank you @gkdn - different changes than I had made, but clearly solving the same issues. I appreciate the pointer to the _debug test target. @treblereel has submitted #222 with changes from GWT, verified in j2cl by running tests as you described. All reactions Sorry, something went wrong. niloc132 mentioned this issue Jul 18, 2024 Implement java.lang.Math.nextAfter, nextUp, nextDown #249 Closed Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Assignees No one assigned Labels None yet Projects None yet Milestone No milestone Development No branches or pull requests 9 participants You can’t perform that action at this time.
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
By popular request, I am listing the things that J2CL team is actively working on apart from continuous improvements and maintenance and what to expect in the next quarters:
Last Edit: Jul 26, 2023
Now
Next
Later
Completed in previous quarters
The J2CL code is production ready and battle tested with Google Apps for years. Only open-source tooling is missing some workflows. All of our improvements to the released code are in sync with Google and you are getting the improvement at the same time as Google gets.
At the moment for J2CL, we are only planning to do dated releases (instead of semantic versioning like v1) and make more tools work in open source over time.
The text was updated successfully, but these errors were encountered:
Are you planning gradle support ? Bazel is not known to any IDE.
Sorry, something went wrong.
https://docs.bazel.build/versions/master/ide.html ? (my main problem with the IntelliJ IDEA plugin though is that it's currently not compatible with latest IDEA 2020.2: bazelbuild/intellij#1998)
i would love to see some gRPC support on this list :)
Are there any workarounds how to run tests, before j2cl_test ll be ported ? It's a critical feature
any updates here?
I update it every now and then but comment date doesn't reflect that (you need to click edited to see the change dates).
edited
Any update on Kotlin support? That would be amazing and java projects are increasingly hybridized with Kotlin
We just started Kotlin work. Our goal is to have something usable by end of the year.
@gkdn that is amazing to hear but Kotlin JS is officially developed and has an excellent and mature support for transpiling Kotlin to JS (and generating typescript types) However while kotlin multiplarform/js is great, and while j2cl allow to transpile Java to js, I feel like the main area for improvement would be for J2CL to leverage existing Kotlin js transpiling ability and to be interoperable with the generated js from Java. If you could work on making it easier to have hybrid Kotlin-Java projects that target js that would be amazing, maybe that the biggest issue is about IDE supports at the boundaries (Kotlin js will not allow calling java code even if this java code transpile to J2CL). Improving this IDE interop between Java and Kotlin JS should be possible in theory, either by contributing directly to the Kotlin js compiler or by making a Kotlin compiler plugin (note that the replacement API for the new Kotlin compiler (K2) is in active development https://youtrack.jetbrains.com/issue/KT-49508 ) Also you might consider using arrow-meta which is a library that helps building compiler plugins. https://github.com/arrow-kt/arrow-meta BTW since you work at Google, maybe you could contact one of the official Google kotlin devs, as you can see here: https://kotlinlang.org/docs/kotlin-foundation.html#current-personnel for some guidance. The best would be to contact Roman Elizarov or to open a youtrack ticket for a collaboration :) I really hope there is the possibility of making a synergy with JetBrains! Anyway just my two cents on how to achieve the best of both worlds.
BTW: I concur that Gradle support would be a step in the right direction for adoption.
Our high demanding customers relies on very Closure style centric Google JavaScript stack (which J2CL is optimized for) and they count every single byte for performance. Unfortunately Kotlin/JS output doesn't match our needs and sometimes in a way that might be contradicting with the Kotlin open-source users needs who rely on different JavaScript stacks.
So for now our main focus we will be enabling Kotlin to those customers. Being said that I already met with Roman on this and we are in contact with JetBreains. We will be still looking into bringing the two worlds together in the long run.
@gkdn I suppose you could apply a post processing step to the generated kotlin-js by feeding it to Closure. You could also work on improving the efficiency of the IR backend. But sure feel free to implement your own incompatible transpiler.
@gkdn just in case, do you have any updates about testing support for Open Source ?
testing support for Open Source
We have an intern working on it at the moment but we will see how it will turn out.
ok, and i suppose you have a deadline right ?
Should be within 2 months; if the project is successful.
It looks like it failed ... So pity :(
Actually basic unit testing support is released, sample app and getting started code is updated accordingly.
I haven't closed the task since it still doesn't support test suites but I will update the notes.
Edit: updated
@gkdn Do you plan to add support for the following methods from Java 9-11? Stream: takeWhile, dropWhile, ofNullable, and iterate String: isBlank, lines, repeat, strip, stripLeading, and stripTrailing List/Set/Map: copyOf Collectors: toUnmodifiable*
And if not, can we make a PR?
We do accept contributions for missing jre methods.
Note that the implementations need to :
Isn't String.repeat is already in the JRE?
String.repeat
String.repeat is indeed already implemented - but can you direct us how to run its tests? (I assume tests are required for such submissions, even though it wasn't on your list ;). )
I see that jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java has a testRepeat method, but there don't seem to be any bazel targets to run individual test classes. #93 (comment) says (and seems to still be correct) that suites cannot run, and only jre/javatests/com/google/j2cl/jre/LangSuite.java references StringTest.
jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java
testRepeat
jre/javatests/com/google/j2cl/jre/LangSuite.java
Here's the other things I tried, just in case I missed the obvious: I noticed that LangSuite is referenced by the Lang j2cl_multi_test in jre/javatests/BUILD`, but running that results in
Lang
j2cl_multi_test
$ bazel test //jre/javatests:Lang ERROR: Skipping '//jre/javatests:Lang': error loading package 'jre/javatests': Label '//javascript/tools/jscompiler/builddefs:flags.bzl' is invalid because 'javascript/tools/jscompiler/builddefs' is not a package; perhaps you meant to put the colon here: '//:javascript/tools/jscompiler/builddefs/flags.bzl'? ERROR: error loading package 'jre/javatests': Label '//javascript/tools/jscompiler/builddefs:flags.bzl' is invalid because 'javascript/tools/jscompiler/builddefs' is not a package; perhaps you meant to put the colon here: '//:javascript/tools/jscompiler/builddefs/flags.bzl'? INFO: Elapsed time: 0.207s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: jre/javatests
Typically when we see //javascript labels, or references at all to jscompiler, it means that this isn't available to be run outside of Google. Removing that import line
//javascript
load("//javascript/tools/jscompiler/builddefs:flags.bzl", "VERBOSE_WARNING_FLAGS_STRICT", "WHITESPACE_ONLY_FLAGS")
and all of the conformance test wiring that depends on it at least advances us to a new error:
$ bazel test //jre/javatests:Lang ERROR: Skipping '//jre/javatests:Lang': error loading package 'jre/javatests': Label '//third_party/bazel_rules/rules_closure/closure:defs.bzl' is invalid because 'third_party/bazel_rules/rules_closure/closure' is not a package; perhaps you meant to put the colon here: '//third_party:bazel_rules/rules_closure/closure/defs.bzl'? ERROR: error loading package 'jre/javatests': Label '//third_party/bazel_rules/rules_closure/closure:defs.bzl' is invalid because 'third_party/bazel_rules/rules_closure/closure' is not a package; perhaps you meant to put the colon here: '//third_party:bazel_rules/rules_closure/closure/defs.bzl'? INFO: Elapsed time: 0.068s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: jre/javatests
Fortunately this is also not terrible to fix: there are two separate load() calls for closure_js_binary - removing the second one still leaves the first (though to just run Lang, I've commented out both of them).
load()
closure_js_binary
Next, I was getting this error:
$ bazel test //jre/javatests:Lang ERROR: Traceback (most recent call last): File "/home/colin/workspace/j2cl/jre/javatests/BUILD", line 85, column 16, in <toplevel> j2cl_multi_test( File "/home/colin/workspace/j2cl/jre/javatests/j2cl_multi_test.bzl", line 50, column 25, in j2cl_multi_test j2kt_native_test( File "/home/colin/workspace/j2cl/build_defs/internal_do_not_use/j2kt_test.bzl", line 16, column 21, in j2kt_native_test j2cl_test_common( File "/home/colin/workspace/j2cl/build_defs/internal_do_not_use/j2cl_test_common.bzl", line 274, column 13, in j2cl_test_common fail("Unknown platform: " + platform) Error in fail: Unknown platform: J2KT-NATIVE
It looks like j2cl_multi_test itself isn't able to run in open source due to J2KT-NATIVE platform not being populated? The code only has branches for CLOSURE and WASM. Next I took the drastic step of removing all j2cl_multi_test (getting past the point of what I could comfortably suggest might even make sense to commit...), and instead wrote a custom test target:
J2KT-NATIVE
CLOSURE
WASM
j2cl_test( name = "Lang", test_class = "com.google.j2cl.jre.LangSuite", runtime_deps = [":emul_tests_lib"], )
This hit compile errors, oddly - it seems that emul_tests_lib itself isn't set up properly? How can this run inside of Google at all? Or do you have entirely separate BUILD files (not just BUILD vs BUILD.bazel), and the checked in BUILD is never used? To fix, I changed my approach, not trying to run tests at all any more, but just get them to build, via bazel build //jre/javatests:emul_tests_lib. First I had to add //third_party:jspecify_annotations-j2cl to the deps list. Next, it seems that the list of disabled errorprone checks in emul_tests_lib is inconsistent with currently checked-in code - TreeMapTest.ConflictingKey either needs a SuppressWarnings on it, or a flag passed to errorprone - I opted for -Xep:ComparableType:OFF, as that seems to be the convention.
emul_tests_lib
bazel build //jre/javatests:emul_tests_lib
//third_party:jspecify_annotations-j2cl
TreeMapTest.ConflictingKey
SuppressWarnings
-Xep:ComparableType:OFF
At this point, emul_tests_lib can succeed in building.
Next, I tried to build (not test) the modified Lang rule above - this failed with a confusing message:
ERROR: /home/colin/workspace/j2cl/jre/javatests/BUILD:129:10: Executing genrule //jre/javatests:genLang_test.js failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument skipped) FAIL: j2cl_test currently supports testing with a single testsuite only. IF YOU HAVE MULTIPLE TESTSUITES, WE DO NOT KNOW IF ALL OF YOUR TESTS PASS OR NOT!
Is it accurate to say that suites don't work, but a single suite would? Regardless, I changed my custom rule to only run StringTest:
j2cl_test( name = "StringTest", test_class = "com.google.j2cl.jre.java.lang.StringTest", runtime_deps = [":emul_tests_lib"], )
This passed a bazel build finally, but tests fail (specifically testIndexOfNull).
testIndexOfNull
-> 02:03:46.792 : Running test: testIndexOfNull -> $module$exports$junit$framework$Assert$impl$m_fail__java_lang_String__void$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:1832:421 -> $testIndexOfNull$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4879:179 [native code] $invokeFunction_$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3869:42 $safeRunTest_$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3855:32 [native code] $goog$testing$TestCase$Continuation_$run$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4226:99 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3780:167 [native code] $goog$testing$TestCase$Continuation_$run$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:4226:99 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3778:47 $goog$Promise$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:2631:32 $JSCompiler_StaticMethods_runTestsReturningPromise$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:3777:22 $JSCompiler_StaticMethods_JSC$2497_execute$$@http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:5582:159 http://localhost:50362/filez/com_google_j2cl/jre/javatests/StringTest_bin.js:5714:53 -> 02:03:46.793 : testIndexOfNull : FAILED
Is there an easier way to go about running tests, so that we can migrate already-working java9-11 stream/optional/collection code into j2cl, complete with tests?
Would any/all of this be suitable for a contribution, so that a CI script could exist that runs these emulation tests, in anticipation of emulation patches?
The JRE unit tests are not ported to open-source so they would not work out of the box.
We are currently swamped with couple of a big projects but if you like to commit to the JRE emulation, the best I can offer at the moment is:
StringTest
jre/javatests/BUILD
bazel test jre/javatests:StringTest
bazel run jre/javatests:StringTest_debug
If you have further questions, let's start a discussion in the discussions section.
@gkdn Thanks a million; it works like a charm.
Great, thank you @gkdn - different changes than I had made, but clearly solving the same issues. I appreciate the pointer to the _debug test target. @treblereel has submitted #222 with changes from GWT, verified in j2cl by running tests as you described.
_debug
No branches or pull requests