ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.1k forks source link

OpenJDK compatibility #1064

Open zilm13 opened 6 years ago

zilm13 commented 6 years ago

It turns out that we should switch to OpenJDK before the end of the 2018 year.

kishansagathiya commented 6 years ago

@zilm13 Just did a quick search for JDK in this repo ( https://github.com/ethereum/ethereumj/blob/08fdf87ef440bdd5926737401c60474c7fd39efc/.travis.yml#L5 https://github.com/ethereum/ethereumj/blob/b0e0ed96add71723b8850aadf3d15c2331b9127a/gradlew#L72 https://github.com/ethereum/ethereumj/blob/55c559de89423c4a1da493c1e2c67d80a169eb30/ethereumj-core/src/test/java/org/ethereum/crypto/ECKeyTest.java#L317 )

Is this just about making sure that we build the project properly(changing gradle settings and travis.yml) or there is more to it? Can you elaborate a bit?

zilm13 commented 6 years ago

@kishansagathiya EthereumJ shoud run properly with OpenJDK installed/set as default instead of Oracle Java. Currently it doesn't.

zilm13 commented 6 years ago
pschweitz commented 6 years ago

Hi,

I built with Oracle JDK 8, and tested to run with JDK 11 in early access.

I got following issue, coming from the spring framework. Removing the dependency from the spring framework could also help to resolve further issues as well:

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$2 (file:/home/interactive/Recordin/lib/spring-core-4.2.0.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

kishansagathiya commented 6 years ago

@pschweitz Can you tell which command you were running, because on building with ./gradlew build -x test I didn't see these messages

pschweitz commented 6 years ago

Hi, It is not at building, but at the running time.

I executed the following commands in a debian 9 fresh install. I prepared this example with an OpenJDK10, which is the actual production release, but with the same result as with the OpenJDK11 in early access:

Prerequisites:

// install gradle and git // as root: ~# apt-get install gradle git

// download OpenJDK 10 // as user (all made in the home dir) : ~$ wget https://download.java.net/java/GA/jdk10/10.0.1/fb4372174a714e6b8c52526dc134031e/10/openjdk-10.0.1_linux-x64_bin.tar.gz ~$ tar -xvzf openjdk-10.0.1_linux-x64_bin.tar.gz

// download of ethereumj // as user (all made in the home dir): ~$ git clone https://github.com/ethereum/ethereumj ~$ cd ethereumj

// run ethereumj using the previously downloaded java: ~/ethereumj$ ./gradlew -Dorg.gradle.java.home=../jdk-10.0.1 run -PmainClass=org.ethereum.samples.BasicSample

// You get following traces: Starting a Gradle Daemon (subsequent builds will be faster)

Configure project : Building version: 1.8.0-SNAPSHOT (from branch develop)

........... several downloads .............

Download https://plugins.gradle.org/m2/org/apache/httpcomponents/project/6/project-6.pom

Configure project :ethereumj-core publishing if master || develop current branch: null

[buildinfo] Properties file path was not found! (Relevant only for builds running on a CI Server)

Task :ethereumj-core:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

Task :ethereumj-core:processResources This will be printed after the build task even if something else calls the build task

Task :ethereumj-core:run 09:42:39.729 INFO [sample] Starting EthereumJ! 09:42:39.749 INFO [general] Starting EthereumJ... May 24, 2018 9:42:40 AM org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@62ddbd7e: startup date [Thu May 24 09:42:40 CEST 2018]; root of context hierarchy May 24, 2018 9:42:41 AM org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition INFO: Overriding bean definition for bean 'transactionStore' with a different definition: replacing [Generic bean: class [org.ethereum.db.TransactionStore]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/home/interactive/ethereumj/ethereumj-core/build/classes/java/main/org/ethereum/db/TransactionStore.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=defaultConfig; factoryMethodName=transactionStore; initMethodName=null; destroyMethodName=(inferred); defined in org.ethereum.config.DefaultConfig] WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$2 (file:/home/interactive/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.2.0.RELEASE/9c807aff0032dea05dcc17a477f2442139671ed7/spring-core-4.2.0.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release May 24, 2018 9:42:41 AM org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker postProcessAfterInitialization INFO: Bean 'org.ethereum.config.CommonConfig' of type [class org.ethereum.config.CommonConfig$$EnhancerBySpringCGLIB$$e907a564] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) May 24, 2018 9:42:41 AM org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker postProcessAfterInitialization INFO: Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b641b7f3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

kishansagathiya commented 6 years ago

@pschweitz That was really helpful. I will try to reproduce it and fix it.

pschweitz commented 6 years ago

Dear colleagues,

I come back to provide you more info on this issue. I made further tests with Oracle Java 11 (early access), and the execution of Ethereumj freezes between following lines:

11:22:03.368 [main] INFO  general - UDP local bound to: xx.xx.xx.xx
11:22:03.380 [main] INFO  sync - Sync Manager: ON

I suppose the way to reproduce the issue is the same than the one I described previously in the thread.

Thank you for your support, as Oracle will no longer support the version 8 of Java one day, and in my opinion, we should alternatively support the next LTS release which is Java 11.

Read more info about: http://www.oracle.com/technetwork/java/javase/eol-135779.html

mkalinin commented 6 years ago

Thanks for heads up! @pschweitz

acoglio commented 5 years ago

Hello,

I'm trying to build EthereumJ on macOS (High Sierra) with OpenJDK 11, via ./gradlew clean fatJar.

Initially I got an error about being unable to determine the Java version from '11.0.1'. Based on information from the web, I changed gradle-4.6-bin.zip to gradle-4.10-bin.zip in gradle/wrapper/gradle-wrapper.properties, and that error disappeared. Should I make a PR with this change?

Still after that, I get compilation errors about not finding the symbols javax.annotation.PreDestroy and javax.annotation.PostConstruct. Any idea how to overcome this?

Thanks.

mkalinin commented 5 years ago

@acoglio

Should I make a PR with this change?

Sure, go ahead!

javax.annotation.PreDestroy and javax.annotation.PostConstruct are used to implicitly handle start ups and shut downs. It could be replaced by explicit calls to methods marked by these annotations, but it probably requires handling of some spring events.

zilm13 commented 5 years ago

@acoglio I guess they were moved out of Java SE, so you need to add it explicitly. Check this: https://github.com/ether-camp/ethereum-harmony/commit/225fded54355a01ed8e5b6dc2beb3a56616cb65e That way I've added jars with packages that were used but excluded in Java 9. Ordinal version is 0 based, so ordinal = 7 is java 8.