Skip to content
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.

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

Java 11 JRE emulation #9831

Closed
rjeeb opened this issue May 19, 2023 · 3 comments
Closed

Java 11 JRE emulation #9831

rjeeb opened this issue May 19, 2023 · 3 comments
Milestone

Comments

@rjeeb
Copy link

rjeeb commented May 19, 2023

Methods to support:

String:

  • lines()
  • isBlank()
  • format() (will not implement, this is missing deliberately from earlier versions of String)
  • repeat()
  • stripTrailing()
  • stripLeading()
  • strip()

Predicate (done):

  • not()

OptionalDouble (done):

  • isEmpty()

OptionalDouble (done):

  • isEmpty()

OptionalLong (done):

  • isEmpty()

CharSequence was split into #9991 so this could be closed as complete.

@rjeeb rjeeb changed the title Java 11 String JRE emulation Java 11 JRE emulation May 19, 2023
@niloc132
Copy link
Contributor

Predicate and Optional* are all merged.

String.format() is likely not feasible - it requires parsing the format string at runtime, and handling the various possible patterns. That sort of code can't be optimized by the compiler without knowing ahead of time what all format strings will be.

* <li>other methods which are not straightforward in JS
* <ul>
* <li>format(String format, Object... args)

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html#syntax

In theory we could require that the format param will be a string literal and pre-compile the formats so that unused formatting code can be pruned. In practice, that sort of change likely wouldn't be accepted to j2cl, so we should consider carefully if we want to introduce that incompatibility.

niloc132 pushed a commit that referenced this issue Jul 24, 2024
…h Java 11 (#9975)

Adds emulation for java.lang.String methods added in Java 11, partially
completing #9831:
* isBlank
* lines
* repeat
* strip
* stripLeading
* stripTrailing

Fixes #9973
Partial #9831
@zbynek
Copy link
Contributor

zbynek commented Jul 29, 2024

Also CharSequence.chars is already implemented:

@niloc132
Copy link
Contributor

niloc132 commented Aug 9, 2024

Closing as fixed, all emulation mentioned here is fixed (CharSequence methods split into
#9991 for later followup).

@niloc132 niloc132 closed this as completed Aug 9, 2024
@niloc132 niloc132 added this to the 2.12 milestone Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants