Skip to content
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

[Java] sbe 1.16.3 generates noisy Java code #766

Closed
hrstoyanov opened this issue Mar 25, 2020 · 4 comments
Closed

[Java] sbe 1.16.3 generates noisy Java code #766

hrstoyanov opened this issue Mar 25, 2020 · 4 comments

Comments

@hrstoyanov
Copy link

Please cleanup the SBE generated Java code. Here is SBE-generated snippet of code:

public SetFileAttributesEncoder putPath(final DirectBuffer src, final int srcOffset, final int length)
    {
        if (length > 1073741824)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 4;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putInt(limit, (int)length, java.nio.ByteOrder.LITTLE_ENDIAN);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

To which the Java compiler says:

..../hasql/message/src/main/java/dynamind/hasql/message/SetFileAttributesEncoder.java:215: warning: [cast] redundant cast to int
        buffer.putInt(limit, (int)length, java.nio.ByteOrder.LITTLE_ENDIAN);

This is very irritating because it is outside the developer's control, pollutes reports and CI builds.

@mjpt777
Copy link
Contributor

mjpt777 commented Mar 25, 2020

We welcome contributions and sponsorship.

@hrstoyanov
Copy link
Author

Thanks @mjpt777 , I was gonna pick this change up, but I see you did it already!
Here is the compiler switches I used to generate the warnings:

subprojects {
    apply plugin: 'java'
    sourceCompatibility = JavaVersion.VERSION_14
    targetCompatibility = JavaVersion.VERSION_14
    tasks.withType(JavaCompile) {
        options.incremental = true
        options.encoding = 'UTF-8'
        sourceCompatibility = JavaVersion.VERSION_14
        targetCompatibility = JavaVersion.VERSION_14
        options.compilerArgs  << "-Xlint"<<"-Xlint:-try"
    }
}

Also, while at that pls upgrade Gradle to 6.3

@mjpt777
Copy link
Contributor

mjpt777 commented Mar 25, 2020

Gradle 6.3 is just released. We will upgrade in time. We only take direct action for customers who provide us with commercial support.

@hrstoyanov
Copy link
Author

That is fine, but Java 14 requires Gradle 6.3

@mjpt777 mjpt777 closed this as completed Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants