Skip to content

Make this library a Java module #79

Closed

Description

@muety

I wanted to use this library in modularized Java application, but, not surprisingly, am getting an error:

Package 'jssc' is declared in module 'jssc', but module 'org.example.myapp' does not read it

I found issue #60 describing a workaround to this. However, wouldn't it be a better solution if jssc was a Java module itself, i.e. declared its own module-info.java?

Activity

  1. tresf commented on Mar 16, 2021

    @tresf

    wouldn't it be a better solution if jssc was a Java module itself, i.e. declared its own module-info.java?

    Sure!

  2. pietrygamat commented on Mar 17, 2021

    @pietrygamat
    Collaborator

    Adding this would require the project to be compiled with jdk 9+, and to make sure the backwards comatibility with jre6 is preserved, some significant changes should be made in pom.xml. I can offer my help, but first I need some clarification:
    Should it be assumed that the library still can be built with jdk7+ for those working on it locally, or can things be simplified, and from now on building the library requires jdk9+ (or even explicitly 11)?

  3. tresf commented on Mar 17, 2021

    @tresf

    @pietrygamat great question. Ideally, JDK8 should ultimately be EOL and dropped. In practice though, (according to a recent JetBrains survey), JDK8 is still the most prominent version by a long shot.

    image

    For this reason, I believe the binaries to be compatibility with JDK8 is the most important moving forward. Compiling to JDK6 was done as a courtesy to @scream3r. When we talked about this on the phone he had quite the interest in maintaining backwards compatible with legacy computers for time to come and the library should be simple, small and it should "just work". To that point, as modules become the norm, we need to ensure they "just work" too.

    The only thing I'd caution against is the way we represent the JSSC version: We should consider bumping to 3.0.0 if we're to change the minimum Java version, so that developers can safely checkout and fork any v2.9.x tag for backports.

    From a high level, it's my instinct that the build system should continue to work with JDK8 if 9+ isn't available. This is based on the fact that JDK8 is still the most prominent version found and is even available as a port to some obscure systems. JDK11: not so much. Furthemore, although JDK9+ is where modules were introduced, Oracle's short lifespan of these Java versions makes them increasingly hard to find, so I'm in strong favor of migrating any JDK9+ tasks/tutorials/CIs to JDK11 (well, probably our only option anyway).

    Hope that's not too much of a mouthful.

  4. tresf commented on Mar 17, 2021

    @tresf

    or can things be simplified

    It's my opinion that the simpler the code, the better. I don't think the code is complex now (the build system is, a bit).

  5. tresf commented on Aug 5, 2021

    @tresf

    @pietrygamat can you help summarize what's needed to close this out? I'm not very familiar with the module system, but we're nearing a new release and as far as I understand the build system is ready with these changes.

  6. pietrygamat commented on Aug 5, 2021

    @pietrygamat
    Collaborator

    Build the release with JDK11 and publish it, I guess. Users depending on artifacts from dependency management systems will be able to get the jar with module support (thanks to #81 )

  7. tresf commented on Aug 5, 2021

    @tresf

    @pietrygamat perfect, thanks. @GMKennedy and I will build with JDK11 and then we'll close when #104 is merged then. :). Note, I've placed some comments in slack about fixing some compiler warnings before release. They aren't directly related to this, but since they're a result of a newer compiler your thoughts are welcome. 🍻

  8. tresf commented on Aug 5, 2021

    @tresf

    Ok, I think this is directly related.... to suppress the compiler warnings the only combination I've found to work is:

    + @SuppressWarnings({ "requires-automatic", "requires-transitive-automatic" })
      open module jssc {
    -     requires org.scijava.nativelib;
    +     requires transitive org.scijava.nativelib;
          exports jssc;
      }

    I believe this is new with the addition of #92 which.

    @pietrygamat I'm going to add this to #105 branch, merge into master today but if you feel that suppressing these is frowned upon feel free to take them back out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions