Skip to content

[JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs#811

Open
maheshrajus wants to merge 5 commits into
amino-os:masterfrom
maheshrajus:java1.6compatible
Open

[JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs#811
maheshrajus wants to merge 5 commits into
amino-os:masterfrom
maheshrajus:java1.6compatible

Conversation

@maheshrajus

Copy link
Copy Markdown
Collaborator
  1. PR is raised for the issues [Experience #656] Update codebase to use JDK 1.6 APIs #695 and [Bug #661] Gradle build succeeds despite using higher version of Java APIs. #676
  2. If any APIs used which are higher than JDK 1.6 version then compilation issues will be thrown
  3. JAVA6_HOME need to be set if we want to compile the code with JDK1.6
    ex: export JAVA6_HOME=/usr/lib/jvm/jdk1.6.X.X
    this we can set in gradle.properties also.

Note:
Document changes we can handle in the issue: #694

Compilation Report:
Screenshot from 2019-07-05 15-54-58

Sample Error: [when we used lambda expression in Amino.Run code]
lamdaError

Comment thread core/src/main/java/amino/run/app/DMSpec.java Outdated
Comment thread build.gradle Outdated
Comment thread build.gradle Outdated
if ((JavaVersion.VERSION_1_6 == sourceCompatibility)
&& (System.env.JAVA6_HOME) != null) {
options.fork = true
options.bootstrapClasspath = files("$System.env.JAVA6_HOME/jre/lib/rt.jar")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Forcing system env var to be fixed JAVA6_HOME for java6 ? It is very stringent. How about programmatically doing that. May be, define a variable in gradle properties for java6 path and override the JAVA_HOME variable Or may be set org.gradle.java.home only for the build context? Or some other way.

Comment thread build.gradle Outdated
Comment thread core/src/integrationTest/java/amino/run/kernel/IntegrationTestBase.java Outdated
Comment thread build.gradle Outdated
options.bootstrapClasspath = files("$System.env.JAVA6_HOME/jre/lib/rt.jar")
}
else {
options.bootstrapClasspath = files("$System.env.JAVA_HOME/jre/lib/rt.jar")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This just silently uses whatever java version is installed on the system? Isn't that exactly the opposite of what you're trying to achieve here?

What you want is to ensure that java 1.6 is installed and used to compile, otherwise generate an error (unless the user explicitly asks to use a different version of java).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@quinton-hoole

This just silently uses whatever java version is installed on the system? Isn't that exactly the opposite of what you're trying to achieve here?

Here when we set java version to JavaVersion.VERSION_1_6 and set JAVA6_HOME to JDK1.6 path then it will take the first case.
that is --> options.bootstrapClasspath = files("$System.env.JAVA6_HOME/jre/lib/rt.jar")
and it will compile code in 1.6 compatible.
Here JAVA6_HOME should point to JDK1.6
ex: export JAVA6_HOME=/usr/lib/jvm/JDK1.6

What you want is to ensure that java 1.6 is installed and used to compile, otherwise generate an error (unless the user explicitly asks to use a different version of java).

When we have only JAVA 1.6 installed in our system and tries to build then gradle is throwing an error by saying that it requires a 1.7+ java version.

So we are using 1.8 JAVA version for Gradle build and we are enforcing the build to use 1.6 java version by setting the below fields explicitly.

def javaVersion = JavaVersion.VERSION_1_6
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
        if (JavaVersion.VERSION_1_6.equals(javaVersion)
            &&  (System.env.JAVA6_HOME != null) {
            options.fork = true
            //for 1.6java compatible we have to set JAVA6_HOME to JDK1.6 path
            options.bootstrapClasspath = files("$System.env.JAVA6_HOME/jre/lib/rt.jar") 
        }
        else {
            options.bootstrapClasspath = files("$System.env.JAVA_HOME/jre/lib/rt.jar")
        }

Currently, with JAVA6_HOME setting to JDK1.6 path, we can catch the code which does not comply with java1.6 version.

Here I am working for how we can set options.bootstrapClasspath to JDK1.6/jre/lib/rt.jar path in the JDK1.6 case without system env variable(JAVA6_HOME)

@quinton-hoole quinton-hoole Jul 15, 2019

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please ask @VenuReddy2103 to explain.
My point was that the desired java version to compile Amino with should be explicitly specified somewhere in the gradle config files that users check out of git. And if it's not specified, an error should be generated.

Right now, if someone deletes the statement:

def javaVersion = JavaVersion.VERSION_1_6

or if they do not have JAVA6_HOME set in their environment, it is not well defined which java version will be used to compile with. I different version could be used on each developers' machine, which is what we're trying to avoid.

public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok, I will check this and modify

@VenuReddy2103 VenuReddy2103 Jul 22, 2019

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ScaleUpFrontendPolicy.Config do not inherit LoadBalancedFrontendPolicy.Config. They are independent classes to hold their respective config. So, this generation of equals() and hashCode() using IDE looks correct to me.

@quinton-hoole quinton-hoole left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See inline comment. I don't think this does what it's intended to do?

@maheshrajus maheshrajus changed the title [JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs WIP-[JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs Jul 18, 2019
@quinton-hoole

Copy link
Copy Markdown
Collaborator

What is the status here @maheshrajus ? Did you discuss with @VenuReddy2103 ? Is this ready for review yet?

Comment thread build.gradle Outdated
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
options.bootstrapClasspath = files("$System.env.JAVA_HOME/jre/lib/rt.jar")
def jdkpath = project.property('jdkPath')

@VenuReddy2103 VenuReddy2103 Jul 22, 2019

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Remove these additional tabs

Comment thread build.gradle Outdated
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
options.bootstrapClasspath = files("$System.env.JAVA_HOME/jre/lib/rt.jar")
def jdkpath = project.property('jdkPath')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Rename jdkPath property to jdk6Path

Comment thread build.gradle Outdated
def jdkpath = project.property('jdkPath')
def folder = new File(jdkpath)
if(!folder.exists()) {
throw new GradleException("JDK 1.6 path does not exist ! Please set the correct 'jdkPath' in gradle.properties file")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Suggest string to be something like this - "JDK 1.6 path is not set. Please set 'jdk6Path' project property in gradle.properties file."

Comment thread build.gradle
if(!folder.exists()) {
throw new GradleException("JDK 1.6 path does not exist ! Please set the correct 'jdkPath' in gradle.properties file")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think, we should execute java --version using this JDK(the one with jdk6Path) internally, extract version and check if it is 1.6 or not. If not, throw exception with string - "jdk6Path project property is set with JDK 1.x path. Please set it with JDK 1.6 path."

@VenuReddy2103

VenuReddy2103 commented Jul 22, 2019

Copy link
Copy Markdown
Collaborator

What is the status here @maheshrajus ? Did you discuss with @VenuReddy2103 ? Is this ready for review yet?

Discussion Summary:

  1. Our current gradle version(4.10) requires java 1.7 or later to be installed. It detects java version internally and throws below error if we don't have 1.7 or later version available. So we must have 1.7 or later installed.
    image
  2. Have jdk6Path property defined in properties file. This must be set with JDK 6 Path. Check and throw exceptions in following cases:
    1. if jdk6Path property is not set
    2. Or if that is set with some JDK other than 1.6. [We can extract java version with the provided jdk6Path property's bin folder, upon executing java --version internally]

NOTE: We just need JRE 1.6(actually require only rt.jar of 1.6). We don't need complete JDK 1.6 to be installed to compile source with 1.6 compatibility. Will check further on this.

@maheshrajus

Copy link
Copy Markdown
Collaborator Author

When JDK1.6 path not set:
image

When JDK1.8 path set:
image

Compilation & examples test report:
image

image
image

@maheshrajus maheshrajus changed the title WIP-[JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs [JDK1.6 compatibile task #695 and #676] Update Amino codebase to use JDK 1.6 APIs Jul 23, 2019
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.

4 participants