jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Package and Class name collision accross modules

Open Stewori opened this issue 1 year ago • 16 comments

Is your suggestion for improvement related to a problem? Please describe.

I observe at least one package and even class name collision between two JabRef Modules:

org.jabref.cli.ArgumentProcessor exists in jabgui and jabkit and both classes are quite different. They have completely different members, so this is more than just a shadowing hack. While technically possible, already the package name clash is bad style. So-called split packages are discouraged in the Java module system and can cause unforeseen issues.

From https://dev.java/learn/modules/intro/:

Packages should have a unique origin, so no two modules can contain types in the same package. If they do, this is called a split package, and the module system will refuse to compile or launch such configurations.

Describe the solution you'd like Please refactor to avoid split packages as it is an unnecessary risk and source of trouble. The earlier this is done, the easier the change will be. I strongly recommend to adjust this before beta phase.

Stewori avatar Oct 08 '25 11:10 Stewori

/assign-me I can complete this task

hexhacker-vee avatar Oct 13 '25 00:10 hexhacker-vee

👋 Hey @vrushabhdhoke, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

For questions on JabRef functionality and the code base, you can consult the JabRef Guru or ask on our Gitter chat.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

github-actions[bot] avatar Oct 13 '25 00:10 github-actions[bot]

/assign-me

JanviNandre avatar Oct 16 '25 14:10 JanviNandre

👋 Hey @JanviNandre, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

For questions on JabRef functionality and the code base, you can consult the JabRef Guru or ask on our Gitter chat.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

github-actions[bot] avatar Oct 16 '25 14:10 github-actions[bot]

⏰ Assignment Reminder

Hi @JanviNandre, this is a friendly reminder about your assignment to this issue.

[!WARNING] This issue will be automatically unassigned in 11 days if there's no activity.

Remember that you can ask the JabRef Guru or DeepWiki about anything regarding JabRef. Additionally, our contributing guide has hints on creating a pull request and a link to our Gitter chat.

How to keep your assignment


If you are working on it, you can prevent automatic unassignment by:

  • Submitting a draft pull request with your progress within 11 days
  • Asking for the 📌 Pinned label if you need more time

We appreciate your contribution and are here to help if needed!

github-actions[bot] avatar Oct 26 '25 12:10 github-actions[bot]

Since this issue appears to be kind of stalled I took a more detailed look myself. It looks like the only problematic packages are org.jabref and org.jabref.cli which collide between the modules org.jabref ("jabgui") and org.jabref.jabkit ("jabkit"). My suggestion is to leave those in jabgui unchanged and rename those in jabkit. That is because org.jabref.Launcher has been in that place already before modularization was introduced, perhaps ever since. Also, as an entry point class it should better not move as external code may rely on it more heavily than on other classes. Also, as the module org.jabref carries kind of the root name it should have the primary privilege to contain packages under that name. Then, how should org.jabref and org.jabref.cli in jabkit be renamed? Taking a look at jabls, it contains a package org.jabref.languageserver.cli, so jabls kind of translates to a package namespace below org.jabref, namely org.jabref.languageserver (in short: "jabls"). It would be consistent to apply the same principle to jabkit, just unlike expanding "ls" to "languageserver" there is nothing to expand with "kit". So, consistently I'd suggest to rename in jabkit the packages org.jabref and org.jabref.cli to org.jabref.kit and org.jabref.kit.cli respectively. There is one more package in jabkit: org.jabref.cli.converter. Even though that package is unaffected by this issue, I'd suggest to rename it consistently to org.jabref.kit.cli.converter. I know, org.jabref.JabKit is an entry point as well. However, it is fairly new compared to org.jabref.Launcher and moving it to a different package probably would not have too much impact since there has not been much time for external code to evolve into using it. Thoughts? @JanviNandre do you think you could draft a PR with this change?

Stewori avatar Nov 03 '25 12:11 Stewori

One more advantage of the suggested solution is that only jabkit would need to be changed. Since no other module in JabRef requires jabkit, no changes to other modules should be required. Furthermore, all packages of jabkit are internal, i.e. none is exported or opened in any way. This fact restricts changes to the jabkit module even more strictly. I assume that there is some utility that launches JabKit.main. All machinery that references the class org.jabref.JabKit would of course need to be adjusted to reference org.jabref.kit.JabKit instead. Getting this right might still be the most challenging part of this issue.

Stewori avatar Nov 03 '25 13:11 Stewori

After a quick search, it looks like the machinery that needs adjustment consists of the files .jbang/JabKitLauncher.java and jabkit/build.gradle.kts. The adjustments would be straight forward.

.jbang/JabKitLauncher.java: old:

import org.jabref.JabKit;
/// This class is required for [jbang](https://www.jbang.dev/)
public class JabKitLauncher {
    public static void main(String[] args) {
        org.jabref.JabKit.main(args);
    }

Why is the fq-name used to call main after one bothered to import JabKit? That can be pruned on this occasion. new:

import org.jabref.kit.JabKit;
/// This class is required for [jbang](https://www.jbang.dev/)
public class JabKitLauncher {
    public static void main(String[] args) {
        JabKit.main(args);
    }

jabkit/build.gradle.kts: old:

group = "org.jabref.jabkit"
version = project.findProperty("projVersion") ?: "100.0.0"
application {
    mainClass.set("org.jabref.JabKit")
    mainModule.set("org.jabref.jabkit")

new:

group = "org.jabref.jabkit"
version = project.findProperty("projVersion") ?: "100.0.0"
application {
    mainClass.set("org.jabref.kit.JabKit")
    mainModule.set("org.jabref.jabkit")

Stewori avatar Nov 03 '25 13:11 Stewori

Should "jabkit" be short for "JabRef toolkit"? Perhaps then better call it org.jabref.toolkit and org.jabref.toolkit.cli respectively?

Stewori avatar Nov 09 '25 13:11 Stewori

One more advantage of the suggested solution is that only jabkit would need to be changed. Since no other module in JabRef requires jabkit,

This is intended 😅. JabKit should be the entry point to JabRef's functionality using the CLI, whereas JabGui is the entry point using a GUI.

All machinery that references the class org.jabref.JabKit would of course need to be adjusted to reference org.jabref.kit.JabKit instead.

This is very fine. .jbang/JabKitLauncher.java needs to be adjusted - which is OK 😅

koppor avatar Nov 09 '25 14:11 koppor

Should "jabkit" be short for "JabRef toolkit"? Perhaps then better call it org.jabref.toolkit and org.jabref.toolkit.cli respectively?

Yes, go ahead 😅

koppor avatar Nov 09 '25 14:11 koppor

@koppor do we need to adjust maven central/sonatype publishing then as well?

Siedlerchr avatar Nov 09 '25 14:11 Siedlerchr

We think that this issue was fixed. Please head to https://builds.jabref.org/main to download a development build and try it out.

For any feedback, add a comment to the pull request at https://github.com/JabRef/jabref/pull/14271.

github-actions[bot] avatar Nov 09 '25 22:11 github-actions[bot]

@koppor do we need to adjust maven central/sonatype publishing then as well?

JabKit (CLI) is not JabLib (.logic and .model published as JAR). This PR touched JabKit only.

koppor avatar Nov 10 '25 07:11 koppor

@koppor do we need to adjust maven central/sonatype publishing then as well?

Hah! I think, there is confusion, why there is cli at the end of the package org.jabref.toolkit.cli. - Maybe, we move up all packages from .cli one level up?

Image

koppor avatar Nov 10 '25 08:11 koppor

As said before, there is already e.g. org.jabref.languageserver.cli. How is that any better (except it was not recently changed)? Do you think the remaining org.jabref.cli package should be renamed to org.jabref.gui.cli?

BTW as a side-effect of making the PR, I added archunit to APIdia https://apidia.net/mvn/com.tngtech.archunit/archunit so I could better understand what's going on in test-support. Maybe, JabRef's test-support module could be added to the API doc too, perhaps hidden by default.

Stewori avatar Nov 10 '25 12:11 Stewori