8333680: com/sun/tools/attach/BasicTests.java fails with "SocketException: Permission denied: connect"
Reviewed-by: sspitsyn, kevinw, lmesnik
This commit is contained in:
parent
512b2b4f14
commit
17bd483ff0
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -28,6 +28,7 @@
|
|||||||
* the given port.
|
* the given port.
|
||||||
*/
|
*/
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class Agent {
|
|||||||
int port = Integer.parseInt(args);
|
int port = Integer.parseInt(args);
|
||||||
System.out.println("Agent connecting back to Tool....");
|
System.out.println("Agent connecting back to Tool....");
|
||||||
Socket s = new Socket();
|
Socket s = new Socket();
|
||||||
s.connect( new InetSocketAddress(port) );
|
s.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), port));
|
||||||
System.out.println("Agent connected to Tool.");
|
System.out.println("Agent connected to Tool.");
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -213,7 +215,8 @@ public class BasicTests {
|
|||||||
|
|
||||||
System.out.println(" - Test: End-to-end connection with agent");
|
System.out.println(" - Test: End-to-end connection with agent");
|
||||||
|
|
||||||
ServerSocket ss = new ServerSocket(0);
|
ServerSocket ss = new ServerSocket();
|
||||||
|
ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
||||||
int port = ss.getLocalPort();
|
int port = ss.getLocalPort();
|
||||||
|
|
||||||
System.out.println(" - Loading Agent.jar into target VM ...");
|
System.out.println(" - Loading Agent.jar into target VM ...");
|
||||||
@ -231,7 +234,8 @@ public class BasicTests {
|
|||||||
|
|
||||||
System.out.println(" - Test: End-to-end connection with RedefineAgent");
|
System.out.println(" - Test: End-to-end connection with RedefineAgent");
|
||||||
|
|
||||||
ServerSocket ss2 = new ServerSocket(0);
|
ServerSocket ss2 = new ServerSocket();
|
||||||
|
ss2.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
||||||
int port2 = ss2.getLocalPort();
|
int port2 = ss2.getLocalPort();
|
||||||
|
|
||||||
System.out.println(" - Loading RedefineAgent.jar into target VM ...");
|
System.out.println(" - Loading RedefineAgent.jar into target VM ...");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -32,6 +32,7 @@
|
|||||||
* 6446941 java.lang.instrument: multiple agent attach fails (first agent chooses capabilities)
|
* 6446941 java.lang.instrument: multiple agent attach fails (first agent chooses capabilities)
|
||||||
*/
|
*/
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -104,7 +105,7 @@ public class RedefineAgent implements ClassFileTransformer {
|
|||||||
int port = Integer.parseInt(args);
|
int port = Integer.parseInt(args);
|
||||||
System.out.println("RedefineAgent connecting back to Tool....");
|
System.out.println("RedefineAgent connecting back to Tool....");
|
||||||
Socket s = new Socket();
|
Socket s = new Socket();
|
||||||
s.connect( new InetSocketAddress(port) );
|
s.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), port));
|
||||||
System.out.println("RedefineAgent connected to Tool.");
|
System.out.println("RedefineAgent connected to Tool.");
|
||||||
|
|
||||||
testRedefine(inst);
|
testRedefine(inst);
|
||||||
|
Loading…
Reference in New Issue
Block a user