Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5b73b288
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看板
提交
5b73b288
编写于
5月 09, 2014
作者:
S
sla
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
Reviewed-by: alanb, dsamersoff, jbachorik
上级
04edbd33
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
155 addition
and
35 deletion
+155
-35
src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java
.../com/sun/tools/attach/AttachOperationFailedException.java
+54
-0
src/share/classes/com/sun/tools/attach/VirtualMachine.java
src/share/classes/com/sun/tools/attach/VirtualMachine.java
+17
-3
src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
...share/classes/sun/tools/attach/HotSpotVirtualMachine.java
+15
-1
src/share/classes/sun/tools/jcmd/JCmd.java
src/share/classes/sun/tools/jcmd/JCmd.java
+14
-1
src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java
src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java
+12
-5
src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
...solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
+10
-4
src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
...laris/classes/sun/tools/attach/SolarisVirtualMachine.java
+10
-4
src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
+3
-3
src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
+2
-2
src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
+3
-3
src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java
...ndows/classes/sun/tools/attach/WindowsVirtualMachine.java
+11
-5
src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
+1
-1
test/sun/management/jmxremote/startstop/JMXStartStopTest.java
.../sun/management/jmxremote/startstop/JMXStartStopTest.java
+3
-3
未找到文件。
src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java
0 → 100644
浏览文件 @
5b73b288
/*
* Copyright (c) 2014, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
com.sun.tools.attach
;
import
java.io.IOException
;
/**
* Exception type to signal that an attach operation failed in the target VM.
*
* <p> This exception can be thrown by the various operations of
* {@link com.sun.tools.attach.VirtualMachine} when the operation
* fails in the target VM. If there is a communication error,
* a regular IOException will be thrown.
*
* @since 1.9
*/
@jdk
.
Exported
public
class
AttachOperationFailedException
extends
IOException
{
private
static
final
long
serialVersionUID
=
2140308168167478043L
;
/**
* Constructs an <code>AttachOperationFailedException</code> with
* the specified detail message.
*
* @param s the detail message.
*/
public
AttachOperationFailedException
(
String
message
)
{
super
(
message
);
}
}
src/share/classes/com/sun/tools/attach/VirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -564,8 +564,15 @@ public abstract class VirtualMachine {
*
* @return The system properties
*
* @throws AttachOperationFailedException
* If the target virtual machine is unable to complete the
* attach operation. A more specific error message will be
* given by {@link AttachOperationFailedException#getMessage()}.
*
* @throws IOException
* If an I/O error occurs
* If an I/O error occurs, a communication error for example,
* that cannot be identified as an error to indicate that the
* operation failed in the target VM.
*
* @see java.lang.System#getProperties
* @see #loadAgentLibrary
...
...
@@ -591,8 +598,15 @@ public abstract class VirtualMachine {
*
* @return The agent properties
*
* @throws AttachOperationFailedException
* If the target virtual machine is unable to complete the
* attach operation. A more specific error message will be
* given by {@link AttachOperationFailedException#getMessage()}.
*
* @throws IOException
* If an I/O error occurs
* If an I/O error occurs, a communication error for example,
* that cannot be identified as an error to indicate that the
* operation failed in the target VM.
*/
public
abstract
Properties
getAgentProperties
()
throws
IOException
;
...
...
src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -257,6 +257,20 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
return
value
;
}
/*
* Utility method to read data into a String.
*/
String
readErrorMessage
(
InputStream
sis
)
throws
IOException
{
byte
b
[]
=
new
byte
[
1024
];
int
n
;
StringBuffer
message
=
new
StringBuffer
();
while
((
n
=
sis
.
read
(
b
))
!=
-
1
)
{
message
.
append
(
new
String
(
b
,
0
,
n
,
"UTF-8"
));
}
return
message
.
toString
();
}
// -- attach timeout support
private
static
long
defaultAttachTimeout
=
5000
;
...
...
src/share/classes/sun/tools/jcmd/JCmd.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2011, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 201
4
, 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
...
...
@@ -33,10 +33,12 @@ import java.util.ArrayList;
import
java.util.Comparator
;
import
java.net.URISyntaxException
;
import
com.sun.tools.attach.AttachOperationFailedException
;
import
com.sun.tools.attach.VirtualMachine
;
import
com.sun.tools.attach.VirtualMachineDescriptor
;
import
com.sun.tools.attach.AgentLoadException
;
import
com.sun.tools.attach.AttachNotSupportedException
;
import
sun.tools.attach.HotSpotVirtualMachine
;
import
sun.tools.jstat.JStatLogger
;
import
sun.jvmstat.monitor.Monitor
;
...
...
@@ -119,6 +121,7 @@ public class JCmd {
pids
.
add
(
arg
.
getPid
()
+
""
);
}
boolean
success
=
true
;
for
(
String
pid
:
pids
)
{
System
.
out
.
println
(
pid
+
":"
);
if
(
arg
.
isListCounters
())
{
...
...
@@ -126,11 +129,16 @@ public class JCmd {
}
else
{
try
{
executeCommandForPid
(
pid
,
arg
.
getCommand
());
}
catch
(
AttachOperationFailedException
ex
)
{
System
.
err
.
println
(
ex
.
getMessage
());
success
=
false
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
success
=
false
;
}
}
}
System
.
exit
(
success
?
0
:
1
);
}
private
static
void
executeCommandForPid
(
String
pid
,
String
command
)
...
...
@@ -150,13 +158,18 @@ public class JCmd {
// read to EOF and just print output
byte
b
[]
=
new
byte
[
256
];
int
n
;
boolean
messagePrinted
=
false
;
do
{
n
=
in
.
read
(
b
);
if
(
n
>
0
)
{
String
s
=
new
String
(
b
,
0
,
n
,
"UTF-8"
);
System
.
out
.
print
(
s
);
messagePrinted
=
true
;
}
}
while
(
n
>
0
);
if
(!
messagePrinted
)
{
System
.
out
.
println
(
"Command executed successfully"
);
}
}
}
vm
.
detach
();
...
...
src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -24,14 +24,14 @@
*/
package
sun.tools.attach
;
import
com.sun.tools.attach.
VirtualMachine
;
import
com.sun.tools.attach.
AttachOperationFailedException
;
import
com.sun.tools.attach.AgentLoadException
;
import
com.sun.tools.attach.AttachNotSupportedException
;
import
com.sun.tools.attach.spi.AttachProvider
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.File
;
import
java.util.Properties
;
/*
* Bsd implementation of HotSpotVirtualMachine
...
...
@@ -191,6 +191,8 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine {
}
if
(
completionStatus
!=
0
)
{
// read from the stream and use that as the error message
String
message
=
readErrorMessage
(
sis
);
sis
.
close
();
// In the event of a protocol mismatch then the target VM
...
...
@@ -205,7 +207,11 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine {
if
(
cmd
.
equals
(
"load"
))
{
throw
new
AgentLoadException
(
"Failed to load agent library"
);
}
else
{
throw
new
IOException
(
"Command failed in target VM"
);
if
(
message
==
null
)
{
throw
new
AttachOperationFailedException
(
"Command failed in target VM"
);
}
else
{
throw
new
AttachOperationFailedException
(
message
);
}
}
}
...
...
@@ -237,8 +243,9 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine {
if
((
off
<
0
)
||
(
off
>
bs
.
length
)
||
(
len
<
0
)
||
((
off
+
len
)
>
bs
.
length
)
||
((
off
+
len
)
<
0
))
{
throw
new
IndexOutOfBoundsException
();
}
else
if
(
len
==
0
)
}
else
if
(
len
==
0
)
{
return
0
;
}
return
BsdVirtualMachine
.
read
(
s
,
bs
,
off
,
len
);
}
...
...
src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -24,14 +24,14 @@
*/
package
sun.tools.attach
;
import
com.sun.tools.attach.
VirtualMachine
;
import
com.sun.tools.attach.
AttachOperationFailedException
;
import
com.sun.tools.attach.AgentLoadException
;
import
com.sun.tools.attach.AttachNotSupportedException
;
import
com.sun.tools.attach.spi.AttachProvider
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.File
;
import
java.util.Properties
;
/*
* Linux implementation of HotSpotVirtualMachine
...
...
@@ -207,6 +207,8 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine {
}
if
(
completionStatus
!=
0
)
{
// read from the stream and use that as the error message
String
message
=
readErrorMessage
(
sis
);
sis
.
close
();
// In the event of a protocol mismatch then the target VM
...
...
@@ -221,7 +223,11 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine {
if
(
cmd
.
equals
(
"load"
))
{
throw
new
AgentLoadException
(
"Failed to load agent library"
);
}
else
{
throw
new
IOException
(
"Command failed in target VM"
);
if
(
message
==
null
)
{
throw
new
AttachOperationFailedException
(
"Command failed in target VM"
);
}
else
{
throw
new
AttachOperationFailedException
(
message
);
}
}
}
...
...
src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -24,15 +24,15 @@
*/
package
sun.tools.attach
;
import
com.sun.tools.attach.
VirtualMachine
;
import
com.sun.tools.attach.
AttachOperationFailedException
;
import
com.sun.tools.attach.AgentLoadException
;
import
com.sun.tools.attach.AttachNotSupportedException
;
import
com.sun.tools.attach.spi.AttachProvider
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.util.Properties
;
/*
* Solaris implementation of HotSpotVirtualMachine.
...
...
@@ -147,11 +147,17 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine {
// If non-0 it means an error but we need to special-case the
// "load" command to ensure that the right exception is thrown.
if
(
completionStatus
!=
0
)
{
// read from the stream and use that as the error message
String
message
=
readErrorMessage
(
sis
);
sis
.
close
();
if
(
cmd
.
equals
(
"load"
))
{
throw
new
AgentLoadException
(
"Failed to load agent library"
);
}
else
{
throw
new
IOException
(
"Command failed in target VM"
);
if
(
message
==
null
)
{
throw
new
AttachOperationFailedException
(
"Command failed in target VM"
);
}
else
{
throw
new
AttachOperationFailedException
(
message
);
}
}
}
...
...
src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
4
, 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
...
...
@@ -198,14 +198,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_BsdVirtualMachine_read
len
=
remaining
;
}
RESTARTABLE
(
read
(
fd
,
buf
+
off
,
len
),
n
);
RESTARTABLE
(
read
(
fd
,
buf
,
len
),
n
);
if
(
n
==
-
1
)
{
JNU_ThrowIOExceptionWithLastError
(
env
,
"read"
);
}
else
{
if
(
n
==
0
)
{
n
=
-
1
;
// EOF
}
else
{
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
+
off
));
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
));
}
}
return
n
;
...
...
src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
浏览文件 @
5b73b288
...
...
@@ -416,14 +416,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_LinuxVirtualMachine_read
len
=
remaining
;
}
RESTARTABLE
(
read
(
fd
,
buf
+
off
,
len
),
n
);
RESTARTABLE
(
read
(
fd
,
buf
,
len
),
n
);
if
(
n
==
-
1
)
{
JNU_ThrowIOExceptionWithLastError
(
env
,
"read"
);
}
else
{
if
(
n
==
0
)
{
n
=
-
1
;
// EOF
}
else
{
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
+
off
));
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
));
}
}
return
n
;
...
...
src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2014,
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
...
...
@@ -161,14 +161,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_SolarisVirtualMachine_read
len
=
remaining
;
}
RESTARTABLE
(
read
(
fd
,
buf
+
off
,
len
),
n
);
RESTARTABLE
(
read
(
fd
,
buf
,
len
),
n
);
if
(
n
==
-
1
)
{
JNU_ThrowIOExceptionWithLastError
(
env
,
"read"
);
}
else
{
if
(
n
==
0
)
{
n
=
-
1
;
// EOF
}
else
{
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
+
off
));
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
n
,
(
jbyte
*
)(
buf
));
}
}
return
n
;
...
...
src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2014,
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
...
...
@@ -24,15 +24,15 @@
*/
package
sun.tools.attach
;
import
com.sun.tools.attach.
VirtualMachine
;
import
com.sun.tools.attach.
AttachOperationFailedException
;
import
com.sun.tools.attach.AgentLoadException
;
import
com.sun.tools.attach.AttachNotSupportedException
;
import
com.sun.tools.attach.spi.AttachProvider
;
import
sun.tools.attach.HotSpotVirtualMachine
;
import
java.io.IOException
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.Random
;
public
class
WindowsVirtualMachine
extends
HotSpotVirtualMachine
{
...
...
@@ -105,11 +105,17 @@ public class WindowsVirtualMachine extends HotSpotVirtualMachine {
// read completion status
int
status
=
readInt
(
is
);
if
(
status
!=
0
)
{
// read from the stream and use that as the error message
String
message
=
readErrorMessage
(
is
);
// special case the load command so that the right exception is thrown
if
(
cmd
.
equals
(
"load"
))
{
throw
new
AgentLoadException
(
"Failed to load agent library"
);
}
else
{
throw
new
IOException
(
"Command failed in target VM"
);
if
(
message
==
null
)
{
throw
new
AttachOperationFailedException
(
"Command failed in target VM"
);
}
else
{
throw
new
AttachOperationFailedException
(
message
);
}
}
}
...
...
src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
浏览文件 @
5b73b288
...
...
@@ -341,7 +341,7 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_WindowsVirtualMachine_readPipe
if
(
nread
==
0
)
{
return
(
jint
)
-
1
;
// EOF
}
else
{
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
nread
,
(
jbyte
*
)(
buf
+
off
));
(
*
env
)
->
SetByteArrayRegion
(
env
,
ba
,
off
,
(
jint
)
nread
,
(
jbyte
*
)(
buf
));
}
}
...
...
test/sun/management/jmxremote/startstop/JMXStartStopTest.java
浏览文件 @
5b73b288
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2014,
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
...
...
@@ -569,7 +569,7 @@ public class JMXStartStopTest {
final
boolean
[]
checks
=
new
boolean
[
3
];
jcmd
(
line
->
{
if
(
line
.
equal
s
(
"java.lang.RuntimeException: Invalid agent state"
))
{
if
(
line
.
contain
s
(
"java.lang.RuntimeException: Invalid agent state"
))
{
checks
[
0
]
=
true
;
}
},
...
...
@@ -580,7 +580,7 @@ public class JMXStartStopTest {
jcmd
(
line
->
{
if
(
line
.
equal
s
(
"java.lang.RuntimeException: Invalid agent state"
))
{
if
(
line
.
contain
s
(
"java.lang.RuntimeException: Invalid agent state"
))
{
checks
[
1
]
=
true
;
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录