-
-
Save xranby/7e326db34a4ed6aa7a72 to your computer and use it in GitHub Desktop.
/* Modified version of http://www.roseindia.net/tutorial/java/corejava/nio/IntBufferIsDirect.html * Testcase below throws exception using gij and gnu classpath
javac IntIsDirect.java # gcj gij + classpath Output:
gij IntIsDirect
Exception in thread "main" java.lang.NoSuchMethodError: method java.nio.Buffer.isDirect with signature ()Z was not fou…
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
/* Modified version of http://www.roseindia.net/tutorial/java/corejava/nio/IntBufferIsDirect.html | |
* Testcase below throws exception using gij and gnu classpath | |
gcj gij + classpath Output: | |
gij IntIsDirect | |
Exception in thread "main" java.lang.NoSuchMethodError: method java.nio.Buffer.isDirect with signature ()Z was not found. | |
at IntIsDirect.main(IntIsDirect.java:12) | |
OpenJDK output: | |
java IntIsDirect | |
((Buffer)int buffer) is direct. | |
int buffer is direct. | |
((Buffer)int buffer) is not direct. | |
int buffer is not direct. | |
*/ | |
import java.nio.*; | |
import java.nio.ByteBuffer; | |
import java.nio.IntBuffer; | |
public class IntIsDirect { | |
public static void main(String[] argv){ | |
ByteBuffer b = ByteBuffer.allocateDirect(512); | |
IntBuffer i = b.asIntBuffer(); | |
// Type cast of IntBuffer to Buffer throws exception using gij + classpath | |
// when calling .isDirect | |
if (((Buffer)i).isDirect()) { | |
System.out.println("((Buffer)int buffer) is direct."); | |
} else { | |
System.out.println("((Buffer)int buffer) is not direct."); | |
} | |
if (i.isDirect()) { | |
System.out.println("int buffer is direct."); | |
} else { | |
System.out.println("int buffer is not direct."); | |
} | |
int[] array = new int[] {1,2,3,4,5}; | |
IntBuffer intBuf = IntBuffer.wrap(array); | |
// Type cast of IntBuffer to Buffer throws exception using gij + classpath | |
// when calling .isDirect | |
if (((Buffer)intBuf).isDirect()) { | |
System.out.println("((Buffer)int buffer) is direct."); | |
} else { | |
System.out.println("((Buffer)int buffer) is not direct."); | |
} | |
if (intBuf.isDirect()) { | |
System.out.println("int buffer is direct."); | |
} else { | |
System.out.println("int buffer is not direct."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment