Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Jun 4, 2021

Modularization of the JDK has been ongoing for several years. Recently
in Java 16 the JDK began enforcing module boundaries by default. While
Elasticsearch does not yet use the module system directly, there are
some side effects even for those projects not modularized (eg #73517).
Before we can even begin to think about how to modularize, we must
Prepare The Way by enforcing packages only exist in a single jar file,
since the module system does not allow packages to coexist in multiple
modules.

This commit adds a precommit check to the build which detects split
packages. The expectation is that we will add the existing split
packages to the ignore list so that any new classes will not exacerbate
the problem, and the work to cleanup these split packages can be
parallelized.

relates #73525

Modularization of the JDK has been ongoing for several years. Recently
in Java 16 the JDK began enforcing module boundaries by default. While
Elasticsearch does not yet use the module system directly, there are
some side effects even for those projects not modularized (eg elastic#73517).
Before we can even begin to think about how to modularize, we must
Prepare The Way by enforcing packages only exist in a single jar file,
since the module system does not allow packages to coexist in multiple
modules.

This commit adds a precommit check to the build which detects split
packages. The expectation is that we will add the existing split
packages to the ignore list so that any new classes will not exacerbate
the problem, and the work to cleanup these split packages can be
parallelized.

relates elastic#73525
@rjernst rjernst added :Delivery/Build Build or test infrastructure v8.0.0 v7.14.0 labels Jun 4, 2021
@elasticmachine elasticmachine added the Team:Delivery Meta label for Delivery team label Jun 4, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@rjernst
Copy link
Member Author

rjernst commented Jun 4, 2021

Note that this is a WIP as far as adding any existing ignores, but the Gradle work is ready to review.

@rjernst rjernst requested a review from mark-vieira June 4, 2021 19:10
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 4, 2021
The plugin classloader exists in its own jar file for legacy reasons,
and while it should go away in the future, it currently duplicates the
package name of the rest of the plugin classes. This commit moves the
classloader into its own unique package.

relates elastic#73784
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 4, 2021
The org.elasticsearch.bootstrap package exists in server with classes
for starting up Elasticsearch. The elasticsearch-core jar has a handful
of classes that were split out from there, namely java version parsing
and jarhell. This commit moves those classes to a new
org.elasticsearch.jdk package so as to not split the server owned
bootstrap package.

relates elastic#73784
return splitPackages;
}

private void filterSplitPackages(Map<String, Set<String>> splitPackages) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Goning back and mutating our findings seems unnecessarily complicated. Why not just filter these out directly in splitPackages(). Since we already have the package/classname there, we can just check against the filter list before adding to the result set.

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer the separation, since the algorithms are clearer (how to find the split packages vs reading through filters).

rjernst added a commit that referenced this pull request Jun 7, 2021
The plugin classloader exists in its own jar file for legacy reasons,
and while it should go away in the future, it currently duplicates the
package name of the rest of the plugin classes. This commit moves the
classloader into its own unique package.

relates #73784
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 7, 2021
The plugin classloader exists in its own jar file for legacy reasons,
and while it should go away in the future, it currently duplicates the
package name of the rest of the plugin classes. This commit moves the
classloader into its own unique package.

relates elastic#73784
rjernst added a commit that referenced this pull request Jun 7, 2021
The org.elasticsearch.bootstrap package exists in server with classes
for starting up Elasticsearch. The elasticsearch-core jar has a handful
of classes that were split out from there, namely java version parsing
and jarhell. This commit moves those classes to a new
org.elasticsearch.jdk package so as to not split the server owned
bootstrap package.

relates #73784
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 7, 2021
The org.elasticsearch.bootstrap package exists in server with classes
for starting up Elasticsearch. The elasticsearch-core jar has a handful
of classes that were split out from there, namely java version parsing
and jarhell. This commit moves those classes to a new
org.elasticsearch.jdk package so as to not split the server owned
bootstrap package.

relates elastic#73784
rjernst added a commit that referenced this pull request Jun 7, 2021
The org.elasticsearch.bootstrap package exists in server with classes
for starting up Elasticsearch. The elasticsearch-core jar has a handful
of classes that were split out from there, namely java version parsing
and jarhell. This commit moves those classes to a new
org.elasticsearch.jdk package so as to not split the server owned
bootstrap package.

relates #73784
rjernst added a commit that referenced this pull request Jun 8, 2021
The plugin classloader exists in its own jar file for legacy reasons,
and while it should go away in the future, it currently duplicates the
package name of the rest of the plugin classes. This commit moves the
classloader into its own unique package.

relates #73784
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 8, 2021
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates elastic#73784
rjernst added a commit that referenced this pull request Jun 8, 2021
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
@rjernst
Copy link
Member Author

rjernst commented Jun 8, 2021

@mark-vieira I think I've addressed all your comments, and I have added ignores for existing split packages. This should be ready for another look.

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 8, 2021
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates elastic#73784
backport elastic#73909
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 8, 2021
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates elastic#73784
Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

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

LGTM, couple questions about comments referring to lucene but don't seem related.

}

tasks.named('splitPackagesAudit').configure {
// Lucene packages should be owned by Lucene!
Copy link
Contributor

Choose a reason for hiding this comment

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

What do these packages have to do with Lucene?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a copy/paste error. I'll fix the comments.

}

tasks.named('splitPackagesAudit').configure {
// Lucene packages should be owned by Lucene!
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, these are org.elasticsearch packages, how do they conflict with Lucene?

rjernst added a commit that referenced this pull request Jun 8, 2021
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
rjernst added a commit that referenced this pull request Jun 8, 2021
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
backport #73909
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 8, 2021
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates elastic#73784
@rjernst rjernst merged commit ab1a2e4 into elastic:master Jun 8, 2021
@rjernst rjernst deleted the modularize1 branch June 8, 2021 22:04
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Jun 8, 2021
Modularization of the JDK has been ongoing for several years. Recently
in Java 16 the JDK began enforcing module boundaries by default. While
Elasticsearch does not yet use the module system directly, there are
some side effects even for those projects not modularized (eg elastic#73517).
Before we can even begin to think about how to modularize, we must
Prepare The Way by enforcing packages only exist in a single jar file,
since the module system does not allow packages to coexist in multiple
modules.

This commit adds a precommit check to the build which detects split
packages. The expectation is that we will add the existing split
packages to the ignore list so that any new classes will not exacerbate
the problem, and the work to cleanup these split packages can be
parallelized.

relates elastic#73525
rjernst added a commit that referenced this pull request Jun 8, 2021
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
rjernst added a commit that referenced this pull request Jun 8, 2021
Modularization of the JDK has been ongoing for several years. Recently
in Java 16 the JDK began enforcing module boundaries by default. While
Elasticsearch does not yet use the module system directly, there are
some side effects even for those projects not modularized (eg #73517).
Before we can even begin to think about how to modularize, we must
Prepare The Way by enforcing packages only exist in a single jar file,
since the module system does not allow packages to coexist in multiple
modules.

This commit adds a precommit check to the build which detects split
packages. The expectation is that we will add the existing split
packages to the ignore list so that any new classes will not exacerbate
the problem, and the work to cleanup these split packages can be
parallelized.

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

Labels

:Delivery/Build Build or test infrastructure >enhancement Team:Delivery Meta label for Delivery team v7.14.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants