Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files test fails with latest openjdk 7 #76

Closed
joshuawarner32 opened this issue Aug 27, 2013 · 6 comments · Fixed by #130
Closed

Files test fails with latest openjdk 7 #76

joshuawarner32 opened this issue Aug 27, 2013 · 6 comments · Fixed by #130
Labels

Comments

@joshuawarner32
Copy link
Collaborator

The files test fails thusly:

java/lang/UnsatisfiedLinkError: java/io/FileInputStream.read()I
at java/io/FileInputStream.read (native)
at java/io/FileInputStream.read (native)
at Files.main (line 64)

Note that this was originally discussed in #74

@joshuawarner32
Copy link
Collaborator Author

Turns out this is because of a recent change in the jdk7 dev branch:

changeset: 5501:bcba89ce0a8c
user: sla
date: Tue Nov 27 09:23:54 2012 +0100
summary: 8003322: Add instrumentation points for tracing of I/O calls

The change replaced the read()| native method with a read0()|, and implemented read()I to defer to read0()I, with some instrumentation.

The fix to make avian compatible is simple:

diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp
index 0cf5e3b..b8173d3 100644
--- a/src/classpath-openjdk.cpp
+++ b/src/classpath-openjdk.cpp
@@ -2002,7 +2002,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
         intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
                   voidPointer(openFile), updateRuntimeData);

-        intercept(t, fileInputStreamClass, "read", "()I",
+        intercept(t, fileInputStreamClass, "read0", "()I",
                   voidPointer(readByteFromFile), updateRuntimeData);

         intercept(t, fileInputStreamClass, "readBytes", "([BII)I",

The trick will be making avian compatible with both the old version and the new version of openjdk.

@joshuawarner32
Copy link
Collaborator Author

@dicej, any thoughts on how we can fix this, while (hopefully) maintaining compatibility with both versions?

@dicej
Copy link
Member

dicej commented Dec 7, 2013

On Fri, 6 Dec 2013, Joshua Warner wrote:

@dicej, any thoughts on how we can fix this, while (hopefully) maintaining
compatibility with both versions?

The intercept function will just do nothing if it can't find the method,
so we should be able to just have two calls to intercept: one for read and
another for read0.

@joshuawarner32
Copy link
Collaborator Author

The read()I method will always be present - the difference is whether it's a native method (old) or a Java method that delegates to read0()I.

The current implementation of intercept won't work because it doesn't pay any attention to the ACC_NATIVE flag; in fact, it unconditionally sets it.

@dicej
Copy link
Member

dicej commented Dec 7, 2013

On Fri, 6 Dec 2013, Joshua Warner wrote:

The read()I method will always be present - the difference is whether it's a
native method (old) or a Java method that delegates to read0()I.

The current implementation of intercept won't work because it doesn't pay
any attention to the ACC_NATIVE flag; in fact, it unconditionally sets it.

Then call findMethodOrNull before calling intercept to see if it's native
or not.

@joshuawarner32
Copy link
Collaborator Author

That would make too much sense. (mild face palm)

Expect a pull request coming your way soon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants