-
Notifications
You must be signed in to change notification settings - Fork 15
Chore: Bump supported versions of Java #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pniedzielski
wants to merge
9
commits into
bloomberg:main
Choose a base branch
from
pniedzielski:chore/java-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CI is failing because of the deprecated version of `actions/upload-artifact`. According to the documentation linked in https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/, our usage of this action is safe to just bump the version number from `v3` to `v4`. Signed-off-by: Patrick M. Niedzielski <[email protected]>
1c28753 to
8cf77ca
Compare
Signed-off-by: Patrick M. Niedzielski <[email protected]>
As it stands, our SDK only supports three old LTS versions of Java. Any user who wants to use the SDK on non-LTS versions, or on reasonably new versions of Java, will be prevented. However, what the code really wants is to know whether we’re on a version of Java before or after Java 9, with which we determine which CRC32 implementation to use. This patch *removes* explicit JDK versioning from `SystemUtil`, which is a breaking change. Signed-off-by: Patrick M. Niedzielski <[email protected]>
8cf77ca to
7581462
Compare
Signed-off-by: Patrick M. Niedzielski <[email protected]>
086f15a to
9be0beb
Compare
Since Java16, we get a number of warnings of the sort
[WARNING] blazingmq-sdk-java/bmq-sdk/src/main/java/com/bloomberg/bmq/impl/infr/proto/BoolMessageProperty.java:[27,25] possible 'this' escape before subclass is fully initialized
These warnings are shown when a class that may serve as a superclass
calls an overridable method in its constructor. If some other class
inherits from that superclass and overrides that method, the
overridden implementation will be called on an object that was not
fully initialized.
We can fix this in a few ways. On one hand, we can avoid calling
methods in class constructors. This works nicely in cases like
`ControlMessageChoice`, which directly forwards to an `init()` method
to null out its member variables. Duplicating this code is not
terrible. However, in more complicated cases, like `PutHeader` and
the like, the methods we call abstract bit manupulation that’s easy to
get wrong. It’s best not to inline that code in the constructors.
On the other hand, we can prevent the methods we call from the class
constructor from being overriden. In all cases we have this warning,
there is a strong case to be made that we don’t want to allow
inheritance. The message classes need to follow the protocol schema
directly, and the protocol classes are also directly tied to the
binary protocol that the BlazingMQ broker uses. We should not allow
users to inject their own behaviors into this parsing.
This patch fixes all “`this` escape” warnings that newer JDK versions
give by marking the classes they’re shown for as `final`.
Signed-off-by: Patrick M. Niedzielski <[email protected]>
Compiling on modern JDKs results in the following warning:
blazingmq-sdk-java/bmq-sdk/src/main/java/com/bloomberg/bmq/impl/infr/proto/EventHeader.java:[255,31] implicit cast from int to byte in compound assignment is possibly lossy
This patch fixes this warning by making the cast explicit.
In Java all bitshift operations result in integral types like `int`
or `long`, never `byte`. So, even though we guarantee that the result
of our bitshift operation must fit within eight bits, its type is
`int`. To silence the warning, we make the cast explicit.
Signed-off-by: Patrick M. Niedzielski <[email protected]>
Compiling on modern JDKs results in the following warning:
[WARNING] blazingmq-sdk-java/bmq-sdk/src/main/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesImpl.java:[234,24] implicit cast from long to int in compound assignment is possibly lossy
This is fired on the line:
// Add padding bytes
totalLength += numPaddingBytes;
where `totalLength` is an `int` and `numPaddingBytes` is a `long`.
However, `numPaddingBytes` is initialized few lines above as
// Read padding bytes
final long numPaddingBytes = input.readByte();
Since `readByte()` returns a `byte`, there’s no reason for this
constant to be `long`. This patch fixes the above warning by avoiding
the needless conversion to `long`.
Signed-off-by: Patrick M. Niedzielski <[email protected]>
[WARNING] blazingmq-sdk-java/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/TestTools.java:[152,16] redundant cast to java.nio.ByteBuffer Signed-off-by: Patrick M. Niedzielski <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Working my way up to Java 25 incrementally. There's several issues to solve first.
Includes #65.