Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4a9e7c12
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看板
提交
4a9e7c12
编写于
3月 15, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010136: Make jrunscript's init.js to work on nashorn
Reviewed-by: lagergren, hannesw
上级
f257643d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
550 addition
and
489 deletion
+550
-489
src/share/classes/com/sun/tools/script/shell/init.js
src/share/classes/com/sun/tools/script/shell/init.js
+550
-489
未找到文件。
src/share/classes/com/sun/tools/script/shell/init.js
浏览文件 @
4a9e7c12
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
3
, 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
...
...
@@ -187,11 +187,31 @@ function jlist(list) {
}
/**
* This is java.lang.System properties wrapped by
jmap
.
* This is java.lang.System properties wrapped by
JSAdapter
.
* For eg. to access java.class.path property, you can use
* the syntax sysProps["java.class.path"]
*/
var
sysProps
=
jmap
(
java
.
lang
.
System
.
getProperties
());
var
sysProps
=
new
JSAdapter
({
__get__
:
function
(
name
)
{
return
java
.
lang
.
System
.
getProperty
(
name
);
},
__has__
:
function
(
name
)
{
return
java
.
lang
.
System
.
getProperty
(
name
)
!=
null
;
},
__getIds__
:
function
()
{
return
java
.
lang
.
System
.
getProperties
().
keySet
().
toArray
();
},
__delete__
:
function
(
name
)
{
java
.
lang
.
System
.
clearProperty
(
name
);
return
true
;
},
__put__
:
function
(
name
,
value
)
{
java
.
lang
.
System
.
setProperty
(
name
,
value
);
},
toString
:
function
()
{
return
"
<system properties>
"
;
}
});
// stdout, stderr & stdin
var
out
=
java
.
lang
.
System
.
out
;
...
...
@@ -199,9 +219,18 @@ var err = java.lang.System.err;
// can't use 'in' because it is a JavaScript keyword :-(
var
inp
=
java
.
lang
.
System
[
"
in
"
];
// useful imports for often used io, net classes
importPackage
(
java
.
io
);
importPackage
(
java
.
net
);
var
BufferedInputStream
=
java
.
io
.
BufferedInputStream
;
var
BufferedOutputStream
=
java
.
io
.
BufferedOutputStream
;
var
BufferedReader
=
java
.
io
.
BufferedReader
;
var
DataInputStream
=
java
.
io
.
DataInputStream
;
var
File
=
java
.
io
.
File
;
var
FileInputStream
=
java
.
io
.
FileInputStream
;
var
FileOutputStream
=
java
.
io
.
FileOutputStream
;
var
InputStream
=
java
.
io
.
InputStream
;
var
InputStreamReader
=
java
.
io
.
InputStreamReader
;
var
OutputStream
=
java
.
io
.
OutputStream
;
var
Reader
=
java
.
io
.
Reader
;
var
URL
=
java
.
net
.
URL
;
/**
* Generic any object to input stream mapper
...
...
@@ -302,7 +331,8 @@ function streamClose(stream) {
*
* @param str input from which script is loaded and evaluated
*/
function
load
(
str
)
{
if
(
typeof
(
load
)
==
'
undefined
'
)
{
var
load
=
function
(
str
)
{
var
stream
=
inStream
(
str
);
var
bstream
=
new
BufferedInputStream
(
stream
);
var
reader
=
new
BufferedReader
(
new
InputStreamReader
(
bstream
));
...
...
@@ -314,6 +344,7 @@ function load(str) {
engine
.
put
(
engine
.
FILENAME
,
oldFilename
);
streamClose
(
stream
);
}
}
}
// file system utilities
...
...
@@ -458,7 +489,7 @@ function dirname(pathname) {
* @param dir name of the new directory
*/
function
mkdir
(
dir
)
{
var
dir
=
pathToFile
(
dir
);
dir
=
pathToFile
(
dir
);
println
(
dir
.
mkdir
()?
"
created
"
:
"
can not create dir
"
);
}
...
...
@@ -469,7 +500,7 @@ function mkdir(dir) {
* @param dir input path name
*/
function
mkdirs
(
dir
)
{
var
dir
=
pathToFile
(
dir
);
dir
=
pathToFile
(
dir
);
println
(
dir
.
mkdirs
()?
"
created
"
:
"
can not create dirs
"
);
}
...
...
@@ -479,7 +510,7 @@ function mkdirs(dir) {
* @param pathname name of the file
*/
function
rm
(
pathname
)
{
file
=
pathToFile
(
pathname
);
var
file
=
pathToFile
(
pathname
);
if
(
!
file
.
exists
())
{
println
(
"
file not found:
"
+
pathname
);
return
false
;
...
...
@@ -674,25 +705,29 @@ function exec(cmd) {
$exit
=
process
.
exitValue
();
}
/**
if
(
typeof
(
exit
)
==
'
undefined
'
)
{
/**
* Exit the shell program.
*
* @param exitCode integer code returned to OS shell.
* optional, defaults to 0
*/
function
exit
(
code
)
{
var
exit
=
function
(
code
)
{
if
(
code
)
{
java
.
lang
.
System
.
exit
(
code
+
0
);
}
else
{
java
.
lang
.
System
.
exit
(
0
);
}
}
}
/**
if
(
typeof
(
quit
)
==
'
undefined
'
)
{
/**
* synonym for exit
*/
function
quit
(
code
)
{
var
quit
=
function
(
code
)
{
exit
(
code
);
}
}
// XML utilities
...
...
@@ -776,7 +811,7 @@ function XSLTransform(inp, style, out) {
}
var
factory
=
javax
.
xml
.
transform
.
TransformerFactory
.
newInstance
();
var
tran
former
;
var
trans
former
;
if
(
style
)
{
transformer
=
factory
.
newTransformer
(
XMLSource
(
style
));
}
else
{
...
...
@@ -839,19 +874,21 @@ function echo(x) {
}
}
/**
if
(
typeof
(
printf
)
==
'
undefined
'
)
{
/**
* This is C-like printf
*
* @param format string to format the rest of the print items
* @param args variadic argument list
*/
function
printf
(
format
,
args
/*, more args*/
)
{
var
printf
=
function
(
format
,
args
/*, more args*/
)
{
var
array
=
java
.
lang
.
reflect
.
Array
.
newInstance
(
java
.
lang
.
Object
,
arguments
.
length
-
1
);
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
array
[
i
]
=
arguments
[
i
+
1
];
}
return
java
.
lang
.
System
.
out
.
printf
(
format
,
array
);
java
.
lang
.
System
.
out
.
printf
(
format
,
array
);
}
}
/**
...
...
@@ -882,3 +919,27 @@ function read(prompt, multiline) {
return
reader
.
readLine
();
}
}
if
(
typeof
(
println
)
==
'
undefined
'
)
{
var
print
=
function
(
str
,
newline
)
{
if
(
typeof
(
str
)
==
'
undefined
'
)
{
str
=
'
undefined
'
;
}
else
if
(
str
==
null
)
{
str
=
'
null
'
;
}
if
(
!
(
out
instanceof
java
.
io
.
PrintWriter
))
{
out
=
new
java
.
io
.
PrintWriter
(
out
);
}
out
.
print
(
String
(
str
));
if
(
newline
)
{
out
.
print
(
'
\n
'
);
}
out
.
flush
();
}
var
println
=
function
(
str
)
{
print
(
str
,
true
);
};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录