-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for ceylon/ceylon-compiler#638: detect Java 7
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
bootstrap/src/main/java/ceylon/modules/bootstrap/Java7Checker.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ceylon.modules.bootstrap; | ||
|
||
public class Java7Checker { | ||
|
||
public static void check() { | ||
String version = System.getProperty("java.version"); | ||
if(version == null || version.isEmpty()){ | ||
System.err.println("Unable to determine Java version (java.version property missing or empty). Aborting."); | ||
System.exit(1); | ||
} | ||
if(!version.startsWith("1.7")){ | ||
System.err.println("Your Java version is not supported: "+version); | ||
System.err.println("Ceylon needs Java 7. Please install it from http://www.java.com"); | ||
System.err.println("Aborting."); | ||
System.exit(1); | ||
} | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ceylon.modules.bootstrap; | ||
|
||
public class Main5 { | ||
public static void main(String[] args) throws Throwable{ | ||
Java7Checker.check(); | ||
org.jboss.modules.Main.main(args); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need JDK7?
We have it working on OpenShift, which only has JDK6.
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an interesting question. I'm not sure if the language module needs it. Certainly
ceylon.file
needs it. And the neither the compiler nor IDE will run on Java 6.afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can't update the web runner anymore. AFAIK the compiler is the only one which really requires Java 7 (don't know why though); but since ceylon-js now uses code that's in ceylon-compiler, we need to use java 7 as well, and the web runner depends on ceylon-js, so...
A solution would be to move some of that code from ceylon-compiler to either ceylon-common or to the CMR (actually what ceylon-js uses from ceylon-compiler are some convenience methods to use the CMR so it would make sense to move them to CMR; if ceylon-js doesn't depend on ceylon-compiler anymore, then we can have a build of all the required projects for the web runner using Java 6 and update it).
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's really the case that the web runner can't be updated to Ceylon M3 (I had thought that it was possible to install Java 7 on OpenShift), then we should take it offline for now. I mean we should do that right now, before people get the wrong impression about the JS compiler.
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I think it needs to be a decision made by the OpenShift guys.
Afaik, it's not something a user can do.
But we have the Ceylon servlet approach working on OpenShift:
--- from recent email discussion ---
ceylonc passes parameters to javac.
This is the command I use to compile Ceylon sources on OpenShift.
${CEYLON_HOME}bin/ceylonc -target 1.6 -source 1.6 -src ${ceyonSrc} -rep ${CEYLON_RUNTIME_REPO} -out ${CEYLON_RUNTIME_REPO} ${srcFilesInLine}
I'm not sure if everything works correct, simple examples that I tried are working.
Afair, it can actually run on JDK6 as well, you just need to configure it properly?
(compile compiler with 1.6 flag)
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's correct that
ceylonc
will pass the-target
(and-source
) options on the javac, so that should indeed work currently even though it's not really documented or tested.There are some places where we'd like to start using 1.7 features in the emitted bytecode though:
default
members to interfaces without breaking implementors, which would require usinginvokedynamic
try
with resources (if we end up implementing it) would be much easier using Java 7 improvedtry
.Does anyone know when OpenShift might start supporting Java 7?
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tombentley Take a look at this blog http://datumedge.blogspot.co.uk/2012/06/java-8-lambdas.html?m=1, it talks a bit about default implementations on interfaces for Java 8 and has pointers to articles to go more in depth. Maybe there's something interesting there?
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was meaning to push my 'indy' branch to github (though not merge it yet) after we got M3 out, because then we'd at least be able to experiment with
invokedynamic
. But it needs a bit of tidy up first, so if it turns out we need to be targetting java 6 bytecode then it can wait.afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I'm not sure we should be targeting JDK6, especially if it means not being able to use any new features that we might need/want.
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the JDK6 is an OpenShift limitation, if there's no way to get around that we might just have to look for other hosting options.
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As several people pointed out to me, it's not just OpenShift. GAE has the same limitation.
afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys, ceylon-js and ceylon-spec and ceylon.language compile fine in JDK 6. The only project that really requires JDK 7 is ceylon-compiler. The problem is that ceylon-js now depends on ceylon-compiler because it uses some convenience methods that I found there to use the CMR. If we move that CMR-related code to the CMR (I don't know why it wasn't there in the first place), then we can eliminate this dependency and then make a build of ceylon-spec, ceylon.language and ceylon-js on JDK 6 to update the web runner. I don't want to do this all by myself because I don't know how much shit will break if I move that code and I don't want to make a copy; it should be a clean refactoring so if someone can help me move at least those two methods I use from
com.redhat.ceylon.compiler.java.util.Util
(makeRepositoryManager
andmakeOutputRepositoryManager
) to the CMR where I believe they belong, we'll be on our way to updating the web runner.afbfdc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenShift guys told us it's easy for us to add a cartridge for Java 7. @alesj said he had someone working on this too, so I expect this issue to be resolved soon.