{"id":15952424,"url":"https://github.com/hakonhall/hybridmodules","last_synced_at":"2025-04-04T04:45:00.284Z","repository":{"id":83403303,"uuid":"135215151","full_name":"hakonhall/hybridmodules","owner":"hakonhall","description":"Hybrid JPMS supporting multiple versions","archived":false,"fork":false,"pushed_at":"2023-11-23T22:25:06.000Z","size":4745,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T16:15:02.781Z","etag":null,"topics":["encapsulation","java","java-dependencies","jpms","module-graph","modules","multiversion","osgi"],"latest_commit_sha":null,"homepage":"https://docs.google.com/document/d/1HJQi3nIEsFpn0IDIDXnNplRoFZEK7fNi4jFB50lvHtM/edit?usp=sharing","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hakonhall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-28T22:34:02.000Z","updated_at":"2022-11-14T00:27:32.000Z","dependencies_parsed_at":"2023-11-23T23:36:54.338Z","dependency_job_id":null,"html_url":"https://github.com/hakonhall/hybridmodules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakonhall%2Fhybridmodules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakonhall%2Fhybridmodules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakonhall%2Fhybridmodules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakonhall%2Fhybridmodules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hakonhall","download_url":"https://codeload.github.com/hakonhall/hybridmodules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123099,"owners_count":20887259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encapsulation","java","java-dependencies","jpms","module-graph","modules","multiversion","osgi"],"created_at":"2024-10-07T13:08:35.521Z","updated_at":"2025-04-04T04:45:00.258Z","avatar_url":"https://github.com/hakonhall.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Hybrid Modules System reference implementation\n\nThis repository contains the reference implementation of the Java Hybrid Module System, 3rd edition. The current specification is [here](\nhttps://docs.google.com/document/d/1HJQi3nIEsFpn0IDIDXnNplRoFZEK7fNi4jFB50lvHtM/edit?usp=sharing). \n\nIn short, Java Hybrid Module System (JHMS) is Java Platform Module System (JPMS) with multi-version support.\n\nJHMS utilizes JPMS at compile and package time: modules are declared in module-info.java, the module path is used during compilation, and the module version can be set, etc.\n\nHowever the dependencies seen at compile time, including the version of these (unlike JPMS), are also seen at run time. \nThe only packages *visible* to a (hybrid) module at run time, are those that are are exported to the module from readable\nmodules. Accessibility in visible packages follows pre-JPMS accessibility, e.g. *setAccessible()* can be used to \ngain reflective access to non-public fields and method. The run time behavior is accomplished through class loader\ntechniques similar to OSGi.\n\nThe JHMS specification defines a set of relaxations to the strict specification that an implementation MAY implement at their discretion. The choices made in the reference implementation are detailed in the below Relaxation section.\n\nIn addition to the reference implementation, this repository also provides tools and tips for migrating plain JARs and OSGi bundles to JHMS in the below Migration section.\n\n## Implementation notes\n\n### Relaxations\n\nBoth Version relaxation (§4.1) and Automatic hybrid modules (§4.2) will be implemented by the reference implementation in a future version.\n\n## Migration\n\nIn making a hybrid module, you may come across a dependency that is not yet provided as a hybrid module. \nSuch a dependency may be a plain JAR intended to be put on the class path, an OSGi bundle JAR, or a modular JAR.\n\nIdeally, all application JARs should be hybrid modular JARs. This is often impractical or impossible and\nwe will describe a way to make the dependencies appear as hybrid modules. These dependencies will work\nas proper hybrid modules, but only if there are no errors made in their conversion to the hybrid module, \nwhich is fragile since the java compiler cannot be used to help upholding the guarantees.\n\nA modular JAR can almost always be taken verbatim as a hybrid modular JAR. But if you have several versions of that module,\nyou must ensure each is updated with their version. The `modularize-jar` described below can be used for this.\n\nThere's a separate section below that deals with OSGi bundle JARs.\n\nFor a plain JAR you can use a tool `modularize-jar` that compiles a `module-info.java` and updates the JAR \nto contain it, making it a modular JAR. Example:\n\n```\nmodularize-jar -u -f commons-lang-2.5.jar --module-info src --module-version 2.5\n```\n\nTODO: How to update the compiled version of the dependencies? Use --module-path with jar!? Can javac be used with --module-path (i.e. no source files - all .class files)?\n\n### OSGi bundles\n\nOSGi bundle JARs contains meta information that can be used to make a hybrid modular JAR:\n\n* `Bundle-SymbolicName` may be suitable as the hybrid module name. Note that a valid module name must consist of valid Java identifiers separated by dots (.).\n* `Bundle-Version` may be suitable as the hybrid module version.\n* `Export-Package` lists the packages the JAR exports, and should match the `exports` in a `module-info.java`.\n* `Import-Package` lists the packages the JAR depends on, and can be used to find which bundles it depends on, which may map 1:1 with dependent hybrid modules.\n\nAfter building the module `bundle`, the tool `bundle/bundle.sh` can be used to extract this information in a way that looks deceivingly close to the content of a `module-info.java`.\n\n```\nbundle/bundle.sh BUNDLE \u003e module-info.java\n```\n\nThe resulting `module-info.java` needs to be fixed:\n\n* The version `@\u003cversion\u003e` following the module name should be removed, but the version should be used in the following `modularize-jar` call.\n* The dependant hybrid modules cannot be deduced by the OSGi metadata. The only time the tool gets this right is when there are no dependencies.\n* If the OSGi bundle JAR contains embedded JAR dependencies, then those needs to be extracted into their own\n  independent JAR files, and be made into hybrid modules, and must be referenced in `requires`.\n\nHaving made `module-info.java`, you can now call `modularize-jar`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakonhall%2Fhybridmodules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakonhall%2Fhybridmodules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakonhall%2Fhybridmodules/lists"}