Go to Post Teams that TRY to win and TRY to do their best end up having students that learn more, learn the value of hard work, and are inspired by the process. - Chris Hibner [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-08-2014, 02:03
Timeroot Timeroot is offline
Registered User
FRC #1717
 
Join Date: Jan 2014
Location: Santa Barbara, CA
Posts: 7
Timeroot is an unknown quantity at this point
How to use Java 5 on the cRIO

Hi!
I know that this is pretty outdated now because ... next year everyone will be on the RoboRIO.
But I'm sure there are some of you still playing with cRIOs and practicing and stuff! My team is just transitioning and going to use Java next year for the first time (well, my team is, I just graduated), and so I was teaching them on our cRIO and I was getting very frustrated that it only supports Java 2. Well, technically, source level 1.3, but it compiles down to 1.2. So I fixed it, and everyone can have boxing and unboxing and generics and stuff!

There are only three files to change.

1) Navigate to your sunspotfrcsdk directory. This is usually in your user directory, e.g. C:\Users\Jimbob\sunspotfrcsdk. Look in the "ant" folder, and open up "compile.xml" in a text editor. Look for where it says

Code:
target="1.2"
source="1.3"
and replace it with

Code:
target="1.5"
source="1.5"
2) In the same ant folder, open up preverify.xml. Look for where it says

Code:
</exec>
</else>
and then insert in the middle,

Code:
</exec>

<exec executable="powershell.exe" dir="@{preverify.dir}">
						<arg value="Get-ChildItem . -Filter *.class -Recurse | Foreach-Object {$bytes  = [System.IO.File]::ReadAllBytes($_.FullName);$offset = 7;$bytes[$offset]   = 46;[System.IO.File]::WriteAllBytes($_.FullName, $bytes); }" />
					</exec>

</else>
3) Start using a modern version of preverify. You can get this from Oracle Java ME SDK 3.*, but since most people won't want to install that, I've also put the executable up on dropbox at https://dl.dropboxusercontent.com/u/.../preverify.exe that you can download (32-bit, so it will work for everyone). Put in sunspotfrcsdk/bin, overwriting the existing preverify.exe. If you want to be able to revert, just rename the old one as preverify_old.exe.

And this should do it! The bytecode is pretty much compatible through almost all major versions of Java, excepting where you get to 1.6's stack map tables or 1.7's invokedynamic opcode. The major version in the compiled class files is set as 49 which the romizer compiler rejects, but the powershell script just overwrites that byte and it all works as far as I can tell.

You might still have some issues with NetBeans highlighting your code and saying that it's set to source version 1.3; I can't find where this is set, yet, in order to get it to cooperate. If anyone else can figure it out, let me know! Now everyone can start using ArrayList<T> again.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:21.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi