Skip to content

Modular structure - #375

Open
jeff5 wants to merge 16 commits into
jython:mainfrom
jeff5:modular-structure
Open

jeff5 wants to merge 16 commits into
jython:mainfrom
jeff5:modular-structure

Conversation

@jeff5

@jeff5 jeff5 commented Mar 14, 2025

Copy link
Copy Markdown
Member

This PR, when it has all its change sets, will restructure the Jython 3 code into a Java module core. The objective is to control visibility of objects that will become API, while allowing us to use package structure internally to the project. (Without Java modularity, everything we make public for re-use between packages internally, becomes public externally.)

It is intended that there be more than one module eventually, but always a small number.

We are applying some off-repo learning (in VSJ4). The first step (adding module definitions) does not achieve the objective: public classes must be allocated to packages that are either exported or not, and in some cases a class must be divided between them. The off-repo work also advanced the functional state of the implementation so we shall bring that in too.

This gets quite difficult so the PR will be draft for a while.

jeff5 added 2 commits March 14, 2025 08:12
Script changes preparatory to introducing modules (in the layout we
found to work in VSJ4).
@jeff5
jeff5 marked this pull request as draft March 14, 2025 09:16
jeff5 added 3 commits March 14, 2025 18:17
This allows us to test creation of the several kinds of Javadoc
publication.
We approximate the package structure we need for safe type system
construction and control of visibility developed in the VSJ prototype.
We reduce the breakage this causes by temporarily making some things
public (opposite to the goal).
@jeff5

jeff5 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member Author

The modularisation that seemed initially a structural question, led to functional improvements and new thoughts: you just can't control visibility as desired and bring the type system into existence in the old way. So the change developed in the prototype repo is extensive.

I'm going to merge a lot of it to this branch. Unfortunately, this will look like a big change all at once. It is really the product of a lot of false starts and re-work, that I'm sparing future readers.

Objects like PyFloat in the main repo carry a lot of Jython 2 code not in the off-repo prototype. It needs revision but I'd like to preserve it for now (e.g. the implementation of __new__ is commented out). I don't want to overwrite it by casually copying in files, although that is a safe approach for many.

jeff5 added 10 commits October 24, 2026 11:59
This is a batch of changed and new files supporting the re-worked type
system. It is not a consistent state, so don't test it.
The core types have evolved with the type system. These changed and new
files relate to that. It is not a consistent state, so don't test it.
Exceptions have changed to be more like their implementation in CPython.
They cannot all be distinct Java types because of the need for
class-assignment, but some can.
We add/update descriptors and exposure mechanisms that have not already
slipped through, and a two actual modules. Many classes lack their full
set of features.

This is not yet a coherent state we can test.
We commit support for 3.11 byte code. Developing support for JVM byte
code leads to some refactoring of these classes.

This is the last of the core runtime code, so we include some updated
tests. The test suite as a whole should not be expected to pass on this
commit.
We update the existing tests to match changes in the core. We have some
tests still to add.

The test suite as a whole (as currently committed) ought to pass.
The type system springs into existence when needed. We have a battery of
tests to check that it does so in full working order, irrespective of
the trigger (even concurrent and re-entrant triggers).
Type attribute access is not correctly synchronised yet, so it's a
mystery that this test doesn't fail.
@jeff5
jeff5 marked this pull request as ready for review October 25, 2026 07:20
@jeff5

jeff5 commented Oct 25, 2026 •

Copy link
Copy Markdown
Member Author

I added my changes in batches that do not correspond to the order of development but have something to do with each other. However, it is not possible to run (or even compile, I expect) until where I take off the "skip ci" marker. After that, code is all additional and (as you can see) the unit tests run.

The last set contains one test. It is interesting because, to my mind, the feature tested is incorrectly synchronised. It should fail, but doesn't on platforms I have tried (x86).

@jeff5 jeff5 mentioned this pull request Oct 25, 2026
As well the files git merge cannot merge, some classes have moved and
other features (exceptions for example) have changed. We address those
changes during the merge.
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.

1 participant