Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
08af5768
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
08af5768
编写于
1月 09, 2009
作者:
M
martin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6792066: src/share/native/java/io/io_util.c clean-ups
Reviewed-by: alanb
上级
d389ef8a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
32 deletion
+34
-32
src/share/native/java/io/io_util.c
src/share/native/java/io/io_util.c
+31
-29
src/share/native/java/io/io_util.h
src/share/native/java/io/io_util.h
+3
-3
未找到文件。
src/share/native/java/io/io_util.c
浏览文件 @
08af5768
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <stddef.h>
#include "jni.h"
#include "jni.h"
#include "jni_util.h"
#include "jni_util.h"
...
@@ -34,9 +35,9 @@
...
@@ -34,9 +35,9 @@
/* IO helper functions */
/* IO helper functions */
int
j
int
readSingle
(
JNIEnv
*
env
,
jobject
this
,
jfieldID
fid
)
{
readSingle
(
JNIEnv
*
env
,
jobject
this
,
jfieldID
fid
)
{
int
nread
;
j
int
nread
;
char
ret
;
char
ret
;
FD
fd
=
GET_FD
(
this
,
fid
);
FD
fd
=
GET_FD
(
this
,
fid
);
if
(
fd
==
-
1
)
{
if
(
fd
==
-
1
)
{
...
@@ -49,7 +50,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
...
@@ -49,7 +50,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
}
else
if
(
nread
==
JVM_IO_ERR
)
{
/* error */
}
else
if
(
nread
==
JVM_IO_ERR
)
{
/* error */
JNU_ThrowIOExceptionWithLastError
(
env
,
"Read error"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"Read error"
);
}
else
if
(
nread
==
JVM_IO_INTR
)
{
}
else
if
(
nread
==
JVM_IO_INTR
)
{
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
0
);
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
NULL
);
}
}
return
ret
&
0xFF
;
return
ret
&
0xFF
;
}
}
...
@@ -71,22 +72,22 @@ outOfBounds(JNIEnv *env, jint off, jint len, jbyteArray array) {
...
@@ -71,22 +72,22 @@ outOfBounds(JNIEnv *env, jint off, jint len, jbyteArray array) {
((
*
env
)
->
GetArrayLength
(
env
,
array
)
-
off
<
len
));
((
*
env
)
->
GetArrayLength
(
env
,
array
)
-
off
<
len
));
}
}
int
j
int
readBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
readBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
jint
len
,
jfieldID
fid
)
jint
off
,
jint
len
,
jfieldID
fid
)
{
{
int
nread
;
j
int
nread
;
char
stackBuf
[
BUF_SIZE
];
char
stackBuf
[
BUF_SIZE
];
char
*
buf
=
0
;
char
*
buf
=
NULL
;
FD
fd
;
FD
fd
;
if
(
IS_NULL
(
bytes
))
{
if
(
IS_NULL
(
bytes
))
{
JNU_ThrowNullPointerException
(
env
,
0
);
JNU_ThrowNullPointerException
(
env
,
NULL
);
return
-
1
;
return
-
1
;
}
}
if
(
outOfBounds
(
env
,
off
,
len
,
bytes
))
{
if
(
outOfBounds
(
env
,
off
,
len
,
bytes
))
{
JNU_ThrowByName
(
env
,
"java/lang/IndexOutOfBoundsException"
,
0
);
JNU_ThrowByName
(
env
,
"java/lang/IndexOutOfBoundsException"
,
NULL
);
return
-
1
;
return
-
1
;
}
}
...
@@ -94,8 +95,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
...
@@ -94,8 +95,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
return
0
;
return
0
;
}
else
if
(
len
>
BUF_SIZE
)
{
}
else
if
(
len
>
BUF_SIZE
)
{
buf
=
malloc
(
len
);
buf
=
malloc
(
len
);
if
(
buf
==
0
)
{
if
(
buf
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
0
);
JNU_ThrowOutOfMemoryError
(
env
,
NULL
);
return
0
;
return
0
;
}
}
}
else
{
}
else
{
...
@@ -112,8 +113,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
...
@@ -112,8 +113,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
(
*
env
)
->
SetByteArrayRegion
(
env
,
bytes
,
off
,
nread
,
(
jbyte
*
)
buf
);
(
*
env
)
->
SetByteArrayRegion
(
env
,
bytes
,
off
,
nread
,
(
jbyte
*
)
buf
);
}
else
if
(
nread
==
JVM_IO_ERR
)
{
}
else
if
(
nread
==
JVM_IO_ERR
)
{
JNU_ThrowIOExceptionWithLastError
(
env
,
"Read error"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"Read error"
);
}
else
if
(
nread
==
JVM_IO_INTR
)
{
/* EOF */
}
else
if
(
nread
==
JVM_IO_INTR
)
{
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
0
);
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
NULL
);
}
else
{
/* EOF */
}
else
{
/* EOF */
nread
=
-
1
;
nread
=
-
1
;
}
}
...
@@ -127,8 +128,9 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
...
@@ -127,8 +128,9 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
void
void
writeSingle
(
JNIEnv
*
env
,
jobject
this
,
jint
byte
,
jfieldID
fid
)
{
writeSingle
(
JNIEnv
*
env
,
jobject
this
,
jint
byte
,
jfieldID
fid
)
{
char
c
=
byte
;
// Discard the 24 high-order bits of byte. See OutputStream#write(int)
int
n
;
char
c
=
(
char
)
byte
;
jint
n
;
FD
fd
=
GET_FD
(
this
,
fid
);
FD
fd
=
GET_FD
(
this
,
fid
);
if
(
fd
==
-
1
)
{
if
(
fd
==
-
1
)
{
JNU_ThrowIOException
(
env
,
"Stream Closed"
);
JNU_ThrowIOException
(
env
,
"Stream Closed"
);
...
@@ -138,26 +140,26 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jfieldID fid) {
...
@@ -138,26 +140,26 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jfieldID fid) {
if
(
n
==
JVM_IO_ERR
)
{
if
(
n
==
JVM_IO_ERR
)
{
JNU_ThrowIOExceptionWithLastError
(
env
,
"Write error"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"Write error"
);
}
else
if
(
n
==
JVM_IO_INTR
)
{
}
else
if
(
n
==
JVM_IO_INTR
)
{
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
0
);
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
NULL
);
}
}
}
}
void
void
writeBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
writeBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
jint
len
,
jfieldID
fid
)
jint
off
,
jint
len
,
jfieldID
fid
)
{
{
int
n
;
j
int
n
;
char
stackBuf
[
BUF_SIZE
];
char
stackBuf
[
BUF_SIZE
];
char
*
buf
=
0
;
char
*
buf
=
NULL
;
FD
fd
;
FD
fd
;
if
(
IS_NULL
(
bytes
))
{
if
(
IS_NULL
(
bytes
))
{
JNU_ThrowNullPointerException
(
env
,
0
);
JNU_ThrowNullPointerException
(
env
,
NULL
);
return
;
return
;
}
}
if
(
outOfBounds
(
env
,
off
,
len
,
bytes
))
{
if
(
outOfBounds
(
env
,
off
,
len
,
bytes
))
{
JNU_ThrowByName
(
env
,
"java/lang/IndexOutOfBoundsException"
,
0
);
JNU_ThrowByName
(
env
,
"java/lang/IndexOutOfBoundsException"
,
NULL
);
return
;
return
;
}
}
...
@@ -165,8 +167,8 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
...
@@ -165,8 +167,8 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
return
;
return
;
}
else
if
(
len
>
BUF_SIZE
)
{
}
else
if
(
len
>
BUF_SIZE
)
{
buf
=
malloc
(
len
);
buf
=
malloc
(
len
);
if
(
buf
==
0
)
{
if
(
buf
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
0
);
JNU_ThrowOutOfMemoryError
(
env
,
NULL
);
return
;
return
;
}
}
}
else
{
}
else
{
...
@@ -188,7 +190,7 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
...
@@ -188,7 +190,7 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
JNU_ThrowIOExceptionWithLastError
(
env
,
"Write error"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"Write error"
);
break
;
break
;
}
else
if
(
n
==
JVM_IO_INTR
)
{
}
else
if
(
n
==
JVM_IO_INTR
)
{
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
0
);
JNU_ThrowByName
(
env
,
"java/io/InterruptedIOException"
,
NULL
);
break
;
break
;
}
}
off
+=
n
;
off
+=
n
;
...
@@ -204,19 +206,19 @@ void
...
@@ -204,19 +206,19 @@ void
throwFileNotFoundException
(
JNIEnv
*
env
,
jstring
path
)
throwFileNotFoundException
(
JNIEnv
*
env
,
jstring
path
)
{
{
char
buf
[
256
];
char
buf
[
256
];
int
n
;
j
int
n
;
jobject
x
;
jobject
x
;
jstring
why
=
NULL
;
jstring
why
=
NULL
;
n
=
JVM_GetLastErrorString
(
buf
,
sizeof
(
buf
));
n
=
JVM_GetLastErrorString
(
buf
,
sizeof
(
buf
));
if
(
n
>
0
)
{
if
(
n
>
0
)
{
why
=
JNU_NewStringPlatform
(
env
,
buf
);
why
=
JNU_NewStringPlatform
(
env
,
buf
);
}
}
x
=
JNU_NewObjectByName
(
env
,
x
=
JNU_NewObjectByName
(
env
,
"java/io/FileNotFoundException"
,
"java/io/FileNotFoundException"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
,
path
,
why
);
path
,
why
);
if
(
x
!=
NULL
)
{
if
(
x
!=
NULL
)
{
(
*
env
)
->
Throw
(
env
,
x
);
(
*
env
)
->
Throw
(
env
,
x
);
}
}
}
}
src/share/native/java/io/io_util.h
浏览文件 @
08af5768
...
@@ -38,9 +38,9 @@ extern jfieldID IO_handle_fdID;
...
@@ -38,9 +38,9 @@ extern jfieldID IO_handle_fdID;
* IO helper functions
* IO helper functions
*/
*/
int
readSingle
(
JNIEnv
*
env
,
jobject
this
,
jfieldID
fid
);
j
int
readSingle
(
JNIEnv
*
env
,
jobject
this
,
jfieldID
fid
);
int
readBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
j
int
readBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
jint
len
,
jfieldID
fid
);
jint
len
,
jfieldID
fid
);
void
writeSingle
(
JNIEnv
*
env
,
jobject
this
,
jint
byte
,
jfieldID
fid
);
void
writeSingle
(
JNIEnv
*
env
,
jobject
this
,
jint
byte
,
jfieldID
fid
);
void
writeBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
void
writeBytes
(
JNIEnv
*
env
,
jobject
this
,
jbyteArray
bytes
,
jint
off
,
jint
len
,
jfieldID
fid
);
jint
len
,
jfieldID
fid
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录