From b92f668c8e6cfdadaab83a2883dfdc8b9fc4933b Mon Sep 17 00:00:00 2001 From: dxu Date: Mon, 19 Aug 2013 12:38:56 -0700 Subject: [PATCH] 8023203: Wrap RandomAccessFile.seek native method into a Java helper method Reviewed-by: alanb, chegar --- make/java/java/mapfile-vers | 2 +- makefiles/mapfiles/libjava/mapfile-vers | 2 +- src/share/classes/java/io/RandomAccessFile.java | 10 +++++++++- src/share/native/java/io/RandomAccessFile.c | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/make/java/java/mapfile-vers b/make/java/java/mapfile-vers index ca33582de..bb06a3d60 100644 --- a/make/java/java/mapfile-vers +++ b/make/java/java/mapfile-vers @@ -100,7 +100,7 @@ SUNWprivate_1.1 { Java_java_io_RandomAccessFile_open; Java_java_io_RandomAccessFile_read; Java_java_io_RandomAccessFile_readBytes; - Java_java_io_RandomAccessFile_seek; + Java_java_io_RandomAccessFile_seek0; Java_java_io_RandomAccessFile_setLength; Java_java_io_RandomAccessFile_write; Java_java_io_RandomAccessFile_writeBytes; diff --git a/makefiles/mapfiles/libjava/mapfile-vers b/makefiles/mapfiles/libjava/mapfile-vers index ca33582de..bb06a3d60 100644 --- a/makefiles/mapfiles/libjava/mapfile-vers +++ b/makefiles/mapfiles/libjava/mapfile-vers @@ -100,7 +100,7 @@ SUNWprivate_1.1 { Java_java_io_RandomAccessFile_open; Java_java_io_RandomAccessFile_read; Java_java_io_RandomAccessFile_readBytes; - Java_java_io_RandomAccessFile_seek; + Java_java_io_RandomAccessFile_seek0; Java_java_io_RandomAccessFile_setLength; Java_java_io_RandomAccessFile_write; Java_java_io_RandomAccessFile_writeBytes; diff --git a/src/share/classes/java/io/RandomAccessFile.java b/src/share/classes/java/io/RandomAccessFile.java index 440cd225c..fd1c712d1 100644 --- a/src/share/classes/java/io/RandomAccessFile.java +++ b/src/share/classes/java/io/RandomAccessFile.java @@ -518,7 +518,15 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @exception IOException if {@code pos} is less than * {@code 0} or if an I/O error occurs. */ - public native void seek(long pos) throws IOException; + public void seek(long pos) throws IOException { + if (pos < 0) { + throw new IOException("Negative seek offset"); + } else { + seek0(pos); + } + } + + private native void seek0(long pos) throws IOException; /** * Returns the length of this file. diff --git a/src/share/native/java/io/RandomAccessFile.c b/src/share/native/java/io/RandomAccessFile.c index 42733fb0b..3251db87f 100644 --- a/src/share/native/java/io/RandomAccessFile.c +++ b/src/share/native/java/io/RandomAccessFile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,7 +123,7 @@ Java_java_io_RandomAccessFile_length(JNIEnv *env, jobject this) { } JNIEXPORT void JNICALL -Java_java_io_RandomAccessFile_seek(JNIEnv *env, +Java_java_io_RandomAccessFile_seek0(JNIEnv *env, jobject this, jlong pos) { FD fd; -- GitLab