Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
bc3a2815
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc3a2815
编写于
2月 08, 2017
作者:
R
rfield
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8173845: JShell API: not patch compatible
Reviewed-by: jlahoda
上级
df990ad7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
162 addition
and
8 deletion
+162
-8
langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
...tools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
+29
-1
langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java
...dk.jshell/share/classes/jdk/jshell/MemoryFileManager.java
+5
-1
langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java
...sses/jdk/jshell/execution/JdiDefaultExecutionControl.java
+3
-1
langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java
...hell/share/classes/jdk/jshell/execution/JdiInitiator.java
+9
-4
langtools/test/jdk/jshell/FileManagerTest.java
langtools/test/jdk/jshell/FileManagerTest.java
+114
-0
langtools/test/jdk/jshell/MyExecutionControl.java
langtools/test/jdk/jshell/MyExecutionControl.java
+2
-1
未找到文件。
langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
浏览文件 @
bc3a2815
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015,
2017
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
...
...
@@ -44,8 +44,10 @@ import java.util.ResourceBundle;
import
java.util.function.BiFunction
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.Supplier
;
import
java.util.stream.Stream
;
import
javax.tools.StandardJavaFileManager
;
import
jdk.internal.jshell.debug.InternalDebugControl
;
import
jdk.jshell.Snippet.Status
;
import
jdk.jshell.spi.ExecutionControl.EngineTerminationException
;
...
...
@@ -92,6 +94,7 @@ public class JShell implements AutoCloseable {
final
BiFunction
<
Snippet
,
Integer
,
String
>
idGenerator
;
final
List
<
String
>
extraRemoteVMOptions
;
final
List
<
String
>
extraCompilerOptions
;
final
Function
<
StandardJavaFileManager
,
StandardJavaFileManager
>
fileManagerMapping
;
private
int
nextKeyIndex
=
1
;
...
...
@@ -115,6 +118,7 @@ public class JShell implements AutoCloseable {
this
.
idGenerator
=
b
.
idGenerator
;
this
.
extraRemoteVMOptions
=
b
.
extraRemoteVMOptions
;
this
.
extraCompilerOptions
=
b
.
extraCompilerOptions
;
this
.
fileManagerMapping
=
b
.
fileManagerMapping
;
try
{
if
(
b
.
executionControlProvider
!=
null
)
{
executionControl
=
b
.
executionControlProvider
.
generate
(
new
ExecutionEnvImpl
(),
...
...
@@ -171,6 +175,7 @@ public class JShell implements AutoCloseable {
ExecutionControlProvider
executionControlProvider
;
Map
<
String
,
String
>
executionControlParameters
;
String
executionControlSpec
;
Function
<
StandardJavaFileManager
,
StandardJavaFileManager
>
fileManagerMapping
;
Builder
()
{
}
...
...
@@ -364,6 +369,28 @@ public class JShell implements AutoCloseable {
return
this
;
}
/**
* Configure the {@code FileManager} to be used by compilation and
* source analysis.
* If not set or passed null, the compiler's standard file manager will
* be used (identity mapping).
* For use in special applications where the compiler's normal file
* handling needs to be overridden. See the file manager APIs for more
* information.
* The file manager input enables forwarding file managers, if this
* is not needed, the incoming file manager can be ignored (constant
* function).
*
* @param mapping a function that given the compiler's standard file
* manager, returns a file manager to use
* @return the {@code Builder} instance (for use in chained
* initialization)
*/
public
Builder
fileManager
(
Function
<
StandardJavaFileManager
,
StandardJavaFileManager
>
mapping
)
{
this
.
fileManagerMapping
=
mapping
;
return
this
;
}
/**
* Builds a JShell state engine. This is the entry-point to all JShell
* functionality. This creates a remote process for execution. It is
...
...
@@ -501,6 +528,7 @@ public class JShell implements AutoCloseable {
* @throws IllegalStateException if this {@code JShell} instance is closed.
*/
public
void
addToClasspath
(
String
path
)
{
checkIfAlive
();
// Compiler
taskFactory
.
addToClasspath
(
path
);
// Runtime
...
...
langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java
浏览文件 @
bc3a2815
...
...
@@ -165,7 +165,9 @@ class MemoryFileManager implements JavaFileManager {
}
public
MemoryFileManager
(
StandardJavaFileManager
standardManager
,
JShell
proc
)
{
this
.
stdFileManager
=
standardManager
;
this
.
stdFileManager
=
proc
.
fileManagerMapping
!=
null
?
proc
.
fileManagerMapping
.
apply
(
standardManager
)
:
standardManager
;
this
.
proc
=
proc
;
}
...
...
@@ -185,6 +187,7 @@ class MemoryFileManager implements JavaFileManager {
}
// Make compatible with Jigsaw
@Override
public
String
inferModuleName
(
Location
location
)
{
try
{
if
(
inferModuleNameMethod
==
null
)
{
...
...
@@ -203,6 +206,7 @@ class MemoryFileManager implements JavaFileManager {
}
// Make compatible with Jigsaw
@Override
public
Iterable
<
Set
<
Location
>>
listLocationsForModules
(
Location
location
)
throws
IOException
{
try
{
if
(
listLocationsForModulesMethod
==
null
)
{
...
...
langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java
浏览文件 @
bc3a2815
...
...
@@ -33,6 +33,7 @@ import java.net.InetAddress;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -97,7 +98,8 @@ public class JdiDefaultExecutionControl extends JdiExecutionControl {
// Set-up the JDI connection
JdiInitiator
jdii
=
new
JdiInitiator
(
port
,
env
.
extraRemoteVMOptions
(),
remoteAgent
,
isLaunch
,
host
,
timeout
);
env
.
extraRemoteVMOptions
(),
remoteAgent
,
isLaunch
,
host
,
timeout
,
Collections
.
emptyMap
());
VirtualMachine
vm
=
jdii
.
vm
();
Process
process
=
jdii
.
process
();
...
...
langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java
浏览文件 @
bc3a2815
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016,
2017
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
...
...
@@ -66,16 +66,20 @@ public class JdiInitiator {
* Start the remote agent and establish a JDI connection to it.
*
* @param port the socket port for (non-JDI) commands
* @param remoteVMOptions any user requested VM options
* @param remoteVMOptions any user requested VM
command-line
options
* @param remoteAgent full class name of remote agent to launch
* @param isLaunch does JDI do the launch? That is, LaunchingConnector,
* otherwise we start explicitly and use ListeningConnector
* @param host explicit hostname to use, if null use discovered
* hostname, applies to listening only (!isLaunch)
* @param timeout the start-up time-out in milliseconds
* @param timeout the start-up time-out in milliseconds. If zero or negative,
* will not wait thus will timeout immediately if not already started.
* @param customConnectorArgs custom arguments passed to the connector.
* These are JDI com.sun.jdi.connect.Connector arguments.
*/
public
JdiInitiator
(
int
port
,
List
<
String
>
remoteVMOptions
,
String
remoteAgent
,
boolean
isLaunch
,
String
host
,
int
timeout
)
{
boolean
isLaunch
,
String
host
,
int
timeout
,
Map
<
String
,
String
>
customConnectorArgs
)
{
this
.
remoteAgent
=
remoteAgent
;
this
.
connectTimeout
=
(
int
)
(
timeout
*
CONNECT_TIMEOUT_FACTOR
);
String
connectorName
...
...
@@ -96,6 +100,7 @@ public class JdiInitiator {
argumentName2Value
.
put
(
"localAddress"
,
host
);
}
}
argumentName2Value
.
putAll
(
customConnectorArgs
);
this
.
connectorArgs
=
mergeConnectorArgs
(
connector
,
argumentName2Value
);
this
.
vm
=
isLaunch
?
launchTarget
()
...
...
langtools/test/jdk/jshell/FileManagerTest.java
0 → 100644
浏览文件 @
bc3a2815
/*
* Copyright (c) 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test 8173845
* @summary test custom file managers
* @build KullaTesting TestingInputStream
* @run testng FileManagerTest
*/
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Set
;
import
javax.tools.ForwardingJavaFileManager
;
import
javax.tools.JavaFileObject
;
import
javax.tools.JavaFileObject.Kind
;
import
javax.tools.StandardJavaFileManager
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
@Test
public
class
FileManagerTest
extends
KullaTesting
{
boolean
encountered
;
class
MyFileManager
extends
ForwardingJavaFileManager
<
StandardJavaFileManager
>
implements
StandardJavaFileManager
{
protected
MyFileManager
(
StandardJavaFileManager
fileManager
)
{
super
(
fileManager
);
}
@Override
public
Iterable
<
JavaFileObject
>
list
(
Location
location
,
String
packageName
,
Set
<
Kind
>
kinds
,
boolean
recurse
)
throws
IOException
{
//System.out.printf("list(%s, %s, %s, %b)\n",
// location, packageName, kinds, recurse);
if
(
packageName
.
equals
(
"java.lang.reflect"
))
{
encountered
=
true
;
}
return
fileManager
.
list
(
location
,
packageName
,
kinds
,
recurse
);
}
@Override
public
Iterable
<?
extends
JavaFileObject
>
getJavaFileObjectsFromFiles
(
Iterable
<?
extends
File
>
files
)
{
return
fileManager
.
getJavaFileObjectsFromFiles
(
files
);
}
@Override
public
Iterable
<?
extends
JavaFileObject
>
getJavaFileObjects
(
File
...
files
)
{
return
fileManager
.
getJavaFileObjects
(
files
);
}
@Override
public
Iterable
<?
extends
JavaFileObject
>
getJavaFileObjectsFromStrings
(
Iterable
<
String
>
names
)
{
return
fileManager
.
getJavaFileObjectsFromStrings
(
names
);
}
@Override
public
Iterable
<?
extends
JavaFileObject
>
getJavaFileObjects
(
String
...
names
)
{
return
fileManager
.
getJavaFileObjects
(
names
);
}
@Override
public
void
setLocation
(
Location
location
,
Iterable
<?
extends
File
>
files
)
throws
IOException
{
fileManager
.
setLocation
(
location
,
files
);
}
@Override
public
Iterable
<?
extends
File
>
getLocation
(
Location
location
)
{
return
fileManager
.
getLocation
(
location
);
}
}
@BeforeMethod
@Override
public
void
setUp
()
{
setUp
(
b
->
b
.
fileManager
(
fm
->
new
MyFileManager
(
fm
)));
}
public
void
testSnippetMemberAssignment
()
{
assertEval
(
"java.lang.reflect.Array.get(new String[1], 0) == null"
);
assertTrue
(
encountered
,
"java.lang.reflect not encountered"
);
}
}
langtools/test/jdk/jshell/MyExecutionControl.java
浏览文件 @
bc3a2815
...
...
@@ -29,6 +29,7 @@ import java.io.OutputStream;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -78,7 +79,7 @@ class MyExecutionControl extends JdiExecutionControl {
+
System
.
getProperty
(
"path.separator"
)
+
System
.
getProperty
(
"user.dir"
));
JdiInitiator
jdii
=
new
JdiInitiator
(
port
,
opts
,
REMOTE_AGENT
,
true
,
null
,
TIMEOUT
);
opts
,
REMOTE_AGENT
,
true
,
null
,
TIMEOUT
,
Collections
.
emptyMap
()
);
VirtualMachine
vm
=
jdii
.
vm
();
Process
process
=
jdii
.
process
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录