Skip to content

Conversation

@i10416
Copy link
Contributor

@i10416 i10416 commented Feb 18, 2022

close #381
scala.js supports java.util.BitSet since 1.9.0

@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from 620998f to e85b165 Compare February 18, 2022 11:13
@johnynek
Copy link
Collaborator

I don't think we can merge this and #376.

Also the tests will be very slow if we don't have the switch for isScalaJs.

Can scala-native handle Java util Bitset?

Finally, this will be binary incompatible.

@johnynek
Copy link
Collaborator

But thanks for the PR!!

Hopefully we can merge some version.

@i10416
Copy link
Contributor Author

i10416 commented Feb 19, 2022

Thank you for review. I will tweak what you pointed out.

I don't think we can merge this and #376

Yes, I think too.
I planed to share source between jvm/js first, then tweak #376

Can scala-native handle Java util Bitset?

AFAIK, scala native does not support java.util.BitSet :(

@i10416
Copy link
Contributor Author

i10416 commented Feb 19, 2022

Also the tests will be very slow if we don't have the switch for isScalaJs.

I think it would be better to switch scala.js/jvm tests based on build settings (e.g. generate util object as sbt-buildinfo do ) rather than BitSetUtil fields. What do you think?

@i10416
Copy link
Contributor Author

i10416 commented Feb 19, 2022

Ah, I found portable-scala/sbt-crossproject#17. IIUC, we need to copy-paste BitSetUtil between jvm and js to add native platform impl later?

@armanbilge
Copy link
Member

armanbilge commented Feb 19, 2022

@i10416 I'm actually about to submit a PR to fix portable-scala/sbt-crossproject#17 :)

AFAIK, scala native does not support java.util.BitSet :(

That's true, but now that Scala.js does you can probably just copy-paste the implementation and tests and make a PR to native. That's how many things get ported to native :)

I think it would be better to switch scala.js/jvm tests based on build settings

I think if you have a dependency on cats-laws in the tests you can just use this:

https://github.com/typelevel/cats/blob/b307688c391a47dc6dd82d42c15edf273bf2471b/kernel-laws/jvm/src/main/scala/cats/platform/Platform.scala

@armanbilge
Copy link
Member

@i10416
Copy link
Contributor Author

i10416 commented Feb 19, 2022

tests will be very slow if we don't have the switch for isScalaJs.

Now that test iteration is switched based on js/jvm, what to do are

  1. merge update: use java.util.BitSet on js platform #384 in future release(or is there a nice trick to keep bincompat?)
  2. wait for Port java.util.BitSet scala-native/scala-native#2565 to be merged/released(thx @armanbilge )
  3. then tweak and finish add native build #376.

@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2022

Codecov Report

Merging #384 (e7bf32b) into main (db5c3df) will decrease coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
- Coverage   96.67%   96.51%   -0.17%     
==========================================
  Files           9        9              
  Lines        1263     1261       -2     
  Branches      122      123       +1     
==========================================
- Hits         1221     1217       -4     
- Misses         42       44       +2     
Impacted Files Coverage Δ
...hared/src/main/scala/cats/parse/BitSetCompat.scala 100.00% <100.00%> (ø)
...shared/src/main/scala/cats/parse/Accumulator.scala 97.56% <0.00%> (-2.44%) ⬇️
core/shared/src/main/scala/cats/parse/Parser.scala 96.25% <0.00%> (-0.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db5c3df...e7bf32b. Read the comment docs.

@johnynek
Copy link
Collaborator

I think it is reasonable to release 0.4.0 and break this minor binary compatibility (isScalaJs, isScalaJvm)...

Those really should have been made private [cats.parse] anyway...

@armanbilge
Copy link
Member

armanbilge commented Feb 20, 2022

FWIW I'd appreciate not bumping and preserving binary-compatibility here instead. It makes downstream cross-builds slightly more complicated when the different platforms are pinned on different versions of the same dependency (I'm thinking about http4s).

Apologies if I am missing something, but why is it so hard to preserve bincompat here? Or is it just undesirable?

@johnynek
Copy link
Collaborator

@armanbilge I'm confused by what you mean.

The only real break to binary compatibility is the symbols isScalaJvm and isScalaJs. I bet no one is actually using those. So, any real dependency won't be broken.

The other errors are for items inside the private object Impl which no one can see without doing some weird reflection hacks, which we don't promise to support.

Do you think there are downstream users that care about the first two?

Or is it something about using scalajs 1.9.0?

@armanbilge
Copy link
Member

FTR I completely agree that its unlikely that removing those will break any downstreams.

However, it's the version bump that got my attention: it will force downstreams to also bump their versions to take on this update.

@johnynek
Copy link
Collaborator

okay, fair point.

Let's add the isScalaJvm, isScalaJs back even though it is inelegant. We can add exclusions for the changes inside private object Impl.

@i10416
Copy link
Contributor Author

i10416 commented Feb 25, 2022

Thank you for reviewing. I will put isScalaJvm and isScalaJs back.

 Removing isScalaJs/isScalaJVM breaks binary compatibility. It is
 unlikely that anyone uses this API, but in order to avoid bumping minor
 version, we put platform check fields back to BitSetUtil for now.
object BitSetUtil {
type Tpe = BitSet

@deprecated("", "0.3.7")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed here to isScalaJVM =false , isScalaJs = false because I think combination of isScalaJVM =true, isScalaJs = false, isScalaJVM =false, isScalaJs = true or isScalaJVM =true, isScalaJs = true does not make sense.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I don't want to have a value that is false. This will be very confusing and more of a wart, if you ask me.

Can we make this the same as it was?

instead we could move the BitSet code to

private[parse] abstract class BitSetImpl {
  type Tpe = BitSet
  //...
}

then have the js and jvm code just extend BitSetImpl something like that would maintain binary compatibility but also not have any falsehoods in the return values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead we could move the BitSet code to ...

Yeah, actually, I thought my idea was not nice too😓

That seems better solution! Thanks!

@i10416
Copy link
Contributor Author

i10416 commented Mar 2, 2022

Mima reports binary compatibility issues due to change from scala.collection.mutable.BitSet to java.util.BitSet but it is ok to suppress them, isn't it?

@i10416
Copy link
Contributor Author

i10416 commented Mar 2, 2022

The other errors are for items inside the private object Impl which no one can see without doing some weird reflection hacks, which we don't promise to support.

Ah, I overlooked this.

@i10416
Copy link
Contributor Author

i10416 commented Mar 2, 2022

Hmmm, doesn't Mima support exclude rules like cats.parse.Parser#Impl.* ?

@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from 971905d to 8a4c6e6 Compare March 2, 2022 18:11
@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from c832d10 to bc9599c Compare March 2, 2022 18:24
@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from 8b8017e to 896ad32 Compare March 3, 2022 03:47
@i10416 i10416 requested a review from johnynek March 3, 2022 03:49
@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from 896ad32 to 3168416 Compare March 4, 2022 06:16
@i10416
Copy link
Contributor Author

i10416 commented Mar 4, 2022

I removed deprecated annotations, which I added just in case though I didn't think someone uses isScalaJs and isScalaJvm api, because I assume you don't like warning on the ground that you regard warning as fatal when checking source before marge (while I felt it makes sense to show deprecated warning).

@i10416
Copy link
Contributor Author

i10416 commented Mar 4, 2022

There remain some mima warnings such as method bitSetFor(Array[Char])scala.collection.mutable.BitSet in object cats.parse.BitSetUtil has a different result type in current version, where it is java.util.BitSet rather than scala.collection.mutable.BitSet filter with: ProblemFilters.exclude[IncompatibleResultTypeProblem]("cats.parse.BitSetUtil.bitSetFor").

Should I suppress them too for now? If we would suppress them, I think we would need to remove the exclude rules in a future release as this change is from 0.3.6 to 0.3.7 only.

@johnynek
Copy link
Collaborator

johnynek commented Mar 5, 2022

yeah, we can suppress those errors.

They are only for scalajs and they are only if for some weird reason users accessed that BitSet abstraction code, and I don't know why they would. So, I would bet it will impact exactly zero users.

Also, let's add an issue to remove isScalaJs/isScalaJvm when we release a breaking change.

@i10416 i10416 requested a review from johnynek March 9, 2022 12:14
@i10416
Copy link
Contributor Author

i10416 commented Mar 16, 2022

@johnynek
Can I ask you to review this PR?

Just a reminder. I'm not in a hurry, of course :)

@johnynek
Copy link
Collaborator

Sorry I missed that you had updated this. It looks good to me. If CI is green I'll merge. Thanks so much for working so much to get this done within the binary compatibility constraints.

@i10416
Copy link
Contributor Author

i10416 commented Mar 16, 2022

Sooooooorry! I will fix this by tommow! 🙇

@johnynek
Copy link
Collaborator

huh... the CI does not seem to be running.

@i10416
Copy link
Contributor Author

i10416 commented Mar 17, 2022

Strang...

@i10416 i10416 force-pushed the use-java-bitset-from-scalajs-1.9.0#381 branch from c755b58 to e7bf32b Compare March 17, 2022 08:52
@i10416 i10416 requested a review from johnynek March 17, 2022 08:54
@johnynek johnynek merged commit 2d8e31c into typelevel:main Mar 17, 2022
@johnynek
Copy link
Collaborator

Thanks for pushing this one through!

@i10416 i10416 mentioned this pull request Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use java.util.BitSet on scalajs

4 participants