brenns10 / yams

YAMS: Awesome MIPS Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building Patched MARS: Generic Typing Problem

thomasrussellmurphy opened this issue · comments

Re-building MARS encountered these errors in part of the Sockets implementation.

mars-sockets/mars/mips/instructions/syscalls/Sockets.java:21: illegal start of type
    private static ArrayList<ServerSocket> serverSockets = new ArrayList<>();
                                                                         ^
mars-sockets/mars/mips/instructions/syscalls/Sockets.java:22: illegal start of type
    private static ArrayList<Socket> sockets = new ArrayList<>();
                                                             ^
mars-sockets/mars/mips/instructions/syscalls/Sockets.java:25: illegal start of type
        serverSockets = new ArrayList<>();
                                      ^
mars-sockets/mars/mips/instructions/syscalls/Sockets.java:26: illegal start of type
        sockets = new ArrayList<>();
                                ^
4 errors

Using Mars4_5-SockMod.jar as created with the above error to run the example gives the error:

Error in [...]/yams/socket-examples.asm line 109->67: Runtime exception at 0x00400080: invalid or unimplemented syscall service: 110 

Additional information: OSX 10.9 running Java 8 Update 40.

It looks like a Java 6/7 diamond operator issue. If I had to guess, I'd say that Java 8 is just your JRE version, and you have an older JDK installed. Try running javac -version to verify.

We could get rid of the diamond inference to make it compatible with Java 6. If we accept my last pull request, I have a new one that gets rid of the patch and instead keeps the Java files in a directory, so we can pretty easily edit them with out dealing with the diff/patch format. Then we could make it Java 6 compatible, if it's a big enough issue.

Confirmed old JDK. javac 1.6.0_65
Installing new JDK. However, shouldn't the generic instantiation include type parameter(s)?

Java 7 introduces diamond inference, which allows the type parameter to be omitted. We can modify the code to not use diamond inference, but the best way to do so would be to accept #3, and then I'll push my branch containing java files instead of the patch, and then we can modify the code.

Well, this would break compatibility with aged MARS compatibility back to 1.5. However, being current should be fine.
Confirmed JDK 8u40 operation of the script.

So, may we merge #3?

Closing issue as wontfix, require Java 7+.