Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

byte code compatibility with 6 ?

 
Jan Goyvaerts
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use JDK7's features (say Coin) and yet compile for JDK6 ?
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don’t know. Is Coin available in Java6? Can you add it to your classpath as a .jar?
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might say in the book we are offering how to add features to the classpath for older versions of Java™.
 
Jan Goyvaerts
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Coin provided as a library in JDK7 ?

I'd rather expect the language changes to be a matter of byte code.
 
Richard Reese
author
Ranch Hand
Posts: 84
5
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java 7 features (COIN) are not available in Java 6. If you want to use the COIN features you have to use Java 7.
 
Jan Goyvaerts
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Reese wrote:Java 7 features (COIN) are not available in Java 6. If you want to use the COIN features you have to use Java 7.


I mean of course to write source code with JDK7 - but - to compile it for version 6. The JDK6 JVM's are only used for runtime. As such the developers benefit from JDK7's features and the users don't need to upgrade to JDK7 yet.

Would that work ?
 
Raymond Tong
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Goyvaerts wrote:
Richard Reese wrote:Java 7 features (COIN) are not available in Java 6. If you want to use the COIN features you have to use Java 7.


I mean of course to write source code with JDK7 - but - to compile it for version 6. The JDK6 JVM's are only used for runtime. As such the developers benefit from JDK7's features and the users don't need to upgrade to JDK7 yet.

Would that work ?

If you use some new features in Java7 but run on JVM6, that would fail. (e.g. Fork/Join)
Because these new features require library which available in Java7+

But if you are using new syntax in Java7, that should be fine. (I have not tried)
(i.e. Improved literal, Diamond Operator, String in Switch)
http://www.java-n-me.com/2012/01/java-7-project-coin-decompiled-part-ii.html
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you cannot use Project Coin features and compile byte code that is compatible with Java 6.

Project Coin is a set of small changes to the Java programming language itself. It's not available as a library - these are changes to the programming language itself. You can't put that in a library.

If you compile with the -target 1.6 switch in Java 7, it will not allow you to use the new Project Coin language features.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic