From c476a4b92edb43e45ff2c693de12539f71444b71 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sat, 21 Nov 2026 08:16:09 +0100 Subject: [PATCH 1/2] Use plain I/O for plain data structures --- .../nbproject/org-netbeans-lib-profiler.sig | 6 +- .../netbeans/lib/profiler/ProfilerClient.java | 13 ++-- .../lib/profiler/server/ProfilerServer.java | 8 +-- .../wireprotocol/AsyncMessageCommand.java | 6 +- .../wireprotocol/CalibrationDataResponse.java | 6 +- .../wireprotocol/ClassLoadedCommand.java | 6 +- .../CodeRegionCPUResultsResponse.java | 6 +- .../lib/profiler/wireprotocol/Command.java | 6 +- .../wireprotocol/DefiningLoaderResponse.java | 6 +- .../wireprotocol/DumpResultsResponse.java | 6 +- .../EventBufferDumpedCommand.java | 6 +- .../GetClassFileBytesCommand.java | 6 +- .../GetClassFileBytesResponse.java | 6 +- .../wireprotocol/GetClassIdCommand.java | 6 +- .../wireprotocol/GetClassIdResponse.java | 6 +- .../GetDefiningClassLoaderCommand.java | 6 +- .../GetMethodNamesForJMethodIdsCommand.java | 6 +- .../wireprotocol/HeapHistogramResponse.java | 6 +- .../InitiateProfilingCommand.java | 70 ++++++++++++------- .../InstrumentMethodGroupCommand.java | 6 +- .../InstrumentMethodGroupData.java | 6 +- .../InstrumentMethodGroupResponse.java | 6 +- .../wireprotocol/InternalStatsResponse.java | 6 +- .../MethodInvokedFirstTimeCommand.java | 6 +- .../wireprotocol/MethodLoadedCommand.java | 6 +- .../wireprotocol/MethodNamesResponse.java | 6 +- .../MonitoredNumbersResponse.java | 6 +- .../ObjectAllocationResultsResponse.java | 6 +- .../lib/profiler/wireprotocol/Response.java | 6 +- .../wireprotocol/RootClassLoadedCommand.java | 6 +- .../SetChangeableInstrParamsCommand.java | 6 +- .../SetUnchangeableInstrParamsCommand.java | 6 +- .../wireprotocol/TakeHeapDumpCommand.java | 6 +- .../wireprotocol/ThreadDumpResponse.java | 8 ++- .../ThreadLivenessStatusResponse.java | 6 +- .../wireprotocol/VMPropertiesResponse.java | 6 +- .../lib/profiler/wireprotocol/WireIO.java | 10 +-- .../jfluid/wireio/CommonWireIOTestCase.java | 12 ++-- 38 files changed, 198 insertions(+), 115 deletions(-) diff --git a/profiler/lib.profiler/nbproject/org-netbeans-lib-profiler.sig b/profiler/lib.profiler/nbproject/org-netbeans-lib-profiler.sig index be068a3e60c3..9714dbfc3a98 100644 --- a/profiler/lib.profiler/nbproject/org-netbeans-lib-profiler.sig +++ b/profiler/lib.profiler/nbproject/org-netbeans-lib-profiler.sig @@ -1,5 +1,5 @@ #Signature file v4.1 -#Version 1.143 +#Version 1.144 CLSS public abstract interface java.io.Serializable @@ -102,7 +102,7 @@ meth public int getCurrentAgentId() meth public int getCurrentInstrType() meth public int getDefiningClassLoaderId(java.lang.String,int) throws org.netbeans.lib.profiler.client.ClientUtils$TargetAppOrVMTerminated meth public int[] getAllocatedObjectsCountResults() throws org.netbeans.lib.profiler.client.ClientUtils$TargetAppOrVMTerminated -meth public java.io.ObjectInputStream getSocketInputStream() +meth public java.io.DataInputStream getSocketInputStream() meth public java.lang.String[][] getMethodNamesForJMethodIds(int[]) throws org.netbeans.lib.profiler.client.ClientUtils$TargetAppOrVMTerminated meth public long getInstrProcessingTime() meth public org.netbeans.lib.profiler.ProfilerEngineSettings getSettings() @@ -4375,7 +4375,7 @@ supr org.netbeans.lib.profiler.wireprotocol.Response hfds agentId,agentVersion,bootClassPath,canInstrumentConstructor,javaClassPath,javaCommand,javaExtDirs,jdkVersionString,jvmArguments,maxHeapSize,startupTimeInCounts,startupTimeMillis,targetMachineOSName,workingDir CLSS public org.netbeans.lib.profiler.wireprotocol.WireIO -cons public init(java.io.ObjectOutputStream,java.io.ObjectInputStream) +cons public init(java.io.DataOutputStream,java.io.DataInputStream) meth public java.lang.Object receiveCommandOrResponse() throws java.io.IOException meth public long wasAlive() meth public void sendComplexCommand(org.netbeans.lib.profiler.wireprotocol.Command) throws java.io.IOException diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/ProfilerClient.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/ProfilerClient.java index 16f2e9f702e9..ca330a3b57a2 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/ProfilerClient.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/ProfilerClient.java @@ -19,9 +19,10 @@ package org.netbeans.lib.profiler; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.net.ConnectException; import java.net.Socket; import java.text.MessageFormat; @@ -369,8 +370,8 @@ public void run() { private final Object instrumentationLock = new Object(); // To make sure all instrumentation-related operations // happen serially private final Object responseLock = new Object(); - private ObjectInputStream socketIn; - private ObjectOutputStream socketOut; + private DataInputStream socketIn; + private DataOutputStream socketOut; private ProfilerEngineSettings settings; private ProfilingSessionStatus status; private volatile Response lastResponse; @@ -770,7 +771,7 @@ public ProfilerEngineSettings getSettings() { // public CPUCallGraphBuilder getCPUCallGraphBuilder() { return ccgb; } // public MemoryCallGraphBuilder getMemoryCallGraphBuilder() { return mcgb; } - public ObjectInputStream getSocketInputStream() { + public DataInputStream getSocketInputStream() { return socketIn; } @@ -1714,8 +1715,8 @@ public void run() { clientSocket = new Socket(host, port); clientSocket.setSoTimeout(0); // ATTENTION: timeout may be found useful eventually... clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); - socketIn = new ObjectInputStream(clientSocket.getInputStream()); + socketOut = new DataOutputStream(clientSocket.getOutputStream()); + socketIn = new DataInputStream(clientSocket.getInputStream()); wireIO = new WireIO(socketOut, socketIn); targetVMAlive = true; // This is in fact an assumption diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/ProfilerServer.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/ProfilerServer.java index f266ccd72f27..aaa987c28319 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/ProfilerServer.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/ProfilerServer.java @@ -383,8 +383,8 @@ public void terminate() { //~ Instance fields ---------------------------------------------------------------------------------------------------------- - private ObjectInputStream socketIn; - private ObjectOutputStream socketOut; + private DataInputStream socketIn; + private DataOutputStream socketOut; private ServerSocket serverSocket; private Socket clientSocket; private WireIO wireIO; @@ -1257,8 +1257,8 @@ private boolean connectToClient() { createInfoFile(); clientSocket = serverSocket.accept(); clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - socketIn = new ObjectInputStream(clientSocket.getInputStream()); - socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); + socketIn = new DataInputStream(clientSocket.getInputStream()); + socketOut = new DataOutputStream(clientSocket.getOutputStream()); wireIO = new WireIO(socketOut, socketIn); connectionOpen = true; System.out.println(CONNECTION_MSG); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/AsyncMessageCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/AsyncMessageCommand.java index 3a3c40bbed5f..b708221955aa 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/AsyncMessageCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/AsyncMessageCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -67,12 +69,12 @@ public String toString() { return "Async message: " + (isPositive() ? "positive" : "negative") + ", message = " + message; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { positive = in.readBoolean(); message = in.readUTF(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeBoolean(positive); out.writeUTF(message); } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CalibrationDataResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CalibrationDataResponse.java index 11f2fd801839..91a8ad497b35 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CalibrationDataResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CalibrationDataResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -77,7 +79,7 @@ public String toString() { return "CalibrationDataResponse, " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int len = in.readInt(); methodEntryExitCallTime = new double[len]; methodEntryExitInnerTime = new double[len]; @@ -100,7 +102,7 @@ void readObject(ObjectInputStream in) throws IOException { timerCountsInSecond[1] = in.readLong(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { int len = methodEntryExitCallTime.length; out.writeInt(len); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ClassLoadedCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ClassLoadedCommand.java index c84d995b8dc3..be3864fa17b7 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ClassLoadedCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ClassLoadedCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -82,7 +84,7 @@ public String toString() { + ((classFileBytes == null) ? "null" : ("" + classFileBytes.length)); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { className = in.readUTF(); thisAndParentLoaderData = new int[3]; @@ -102,7 +104,7 @@ void readObject(ObjectInputStream in) throws IOException { threadInCallGraph = in.readBoolean(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeUTF(className); for (int i = 0; i < 3; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CodeRegionCPUResultsResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CodeRegionCPUResultsResponse.java index 21f5eb6dca99..ca30bfc096dc 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CodeRegionCPUResultsResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/CodeRegionCPUResultsResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -59,7 +61,7 @@ public String toString() { return "CodeRegionCPUResultsResponse, length: " + results.length + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int len = in.readInt(); results = new long[len]; @@ -68,7 +70,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(results.length); for (int i = 0; i < results.length; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Command.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Command.java index 1cd6531a8e4d..fbe82297533e 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Command.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Command.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -213,9 +215,9 @@ void setType(int type) { this.type = type; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DefiningLoaderResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DefiningLoaderResponse.java index 4c59f5897504..d93a546c17d1 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DefiningLoaderResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DefiningLoaderResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -63,11 +65,11 @@ public String toString() { return "DefiningLoaderResponse, loaderId: " + loaderId + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { loaderId = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(loaderId); } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DumpResultsResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DumpResultsResponse.java index 80f188fb8b1a..8b566ddfd782 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DumpResultsResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/DumpResultsResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -58,11 +60,11 @@ public String toString() { return "DumpResultsResponse, timeStamp: " + dumpAbsTimeStamp + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { dumpAbsTimeStamp = in.readLong(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeLong(dumpAbsTimeStamp); } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/EventBufferDumpedCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/EventBufferDumpedCommand.java index d31644cf18d6..920034181c23 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/EventBufferDumpedCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/EventBufferDumpedCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -85,7 +87,7 @@ public String getEventBufferFileName() { return eventBufferFileName; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { boolean hasBuffer; bufSize = in.readInt(); @@ -112,7 +114,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(bufSize); out.writeBoolean(buffer != null); if (buffer != null) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesCommand.java index e323f964c262..6b823ad5cfb6 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesCommand.java @@ -18,6 +18,8 @@ */ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -51,7 +53,7 @@ public String[] getClasses() { return classes; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int nClasses = in.readInt(); if (nClasses == 0) { @@ -67,7 +69,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { if (classes == null) { out.writeInt(0); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesResponse.java index 2c9ad623390c..d57467285d19 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassFileBytesResponse.java @@ -18,6 +18,8 @@ */ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -52,7 +54,7 @@ public String toString() { return "GetClassFileBytesResponse, classes: " + classBytes.length + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int nClasses = in.readInt(); if (nClasses == 0) { @@ -71,7 +73,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(classBytes.length); for (int i = 0; i < classBytes.length; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdCommand.java index 4645297a6cb8..8670a4de4dec 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -88,12 +90,12 @@ public String toString() { + ", classLoaderId: " + classLoaderId; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { className = in.readUTF(); classLoaderId = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeUTF(className); out.writeInt(classLoaderId); } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdResponse.java index ade7f7a6d80d..896f7317b7ee 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetClassIdResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -60,11 +62,11 @@ public String toString() { return "GetClassIdResponse, classId: " + classId + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { classId = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(classId); } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetDefiningClassLoaderCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetDefiningClassLoaderCommand.java index 4f32633373f8..24a05401c030 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetDefiningClassLoaderCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetDefiningClassLoaderCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -66,12 +68,12 @@ public String toString() { return super.toString() + ", className: " + className + ", classLoaderId: " + classLoaderId; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { className = in.readUTF(); classLoaderId = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeUTF(className); out.writeInt(classLoaderId); } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetMethodNamesForJMethodIdsCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetMethodNamesForJMethodIdsCommand.java index 06342d19618b..8b65ddc897d7 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetMethodNamesForJMethodIdsCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/GetMethodNamesForJMethodIdsCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -58,7 +60,7 @@ public String toString() { return super.toString() + ", length: " + methodIds.length; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int len = in.readInt(); methodIds = new int[len]; @@ -67,7 +69,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(methodIds.length); for (int i = 0; i < methodIds.length; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/HeapHistogramResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/HeapHistogramResponse.java index 8db802c44889..9806d4b4a58c 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/HeapHistogramResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/HeapHistogramResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -81,7 +83,7 @@ public long[] getBytes() { return bytes; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { long t = in.readLong(); time = new Date(t); int len = in.readInt(); @@ -111,7 +113,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeLong(time.getTime()); out.writeInt(newNames.length); for (int i = 0; i < newNames.length; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InitiateProfilingCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InitiateProfilingCommand.java index 575b82509f02..fc074b8a1cd2 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InitiateProfilingCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InitiateProfilingCommand.java @@ -19,9 +19,9 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; /** * Request from the client to the back end to initiate TA instrumentation of the given type. @@ -131,42 +131,58 @@ public String toString() { return super.toString() + ", instrType = " + instrType; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + @Override + void readObject(DataInputStream in) throws IOException { instrType = in.readInt(); - - int len = in.readInt(); - classNames = new String[len]; - - for (int i = 0; i < len; i++) { - classNames[i] = in.readUTF().intern(); // Interning is important, since checks are through '==' - } - + classNames = readStringArr(in, true); // Interning is important, since checks are through '==' instrSpawnedThreads = in.readBoolean(); startProfilingPointsActive = in.readBoolean(); - try { - profilingPointIDs = (int[]) in.readObject(); - profilingPointHandlers = (String[]) in.readObject(); - profilingPointInfos = (String[]) in.readObject(); - } catch (ClassNotFoundException e) { - IOException ioe = new IOException(); - ioe.initCause(e); - throw ioe; + profilingPointIDs = new int[in.readInt()]; + for (int i = 0; i < profilingPointIDs.length; i++) { + profilingPointIDs[i] = in.readInt(); } + + profilingPointHandlers = readStringArr(in, false); + profilingPointInfos = readStringArr(in, false); } - void writeObject(ObjectOutputStream out) throws IOException { + @Override + void writeObject(DataOutputStream out) throws IOException { out.writeInt(instrType); - out.writeInt(classNames.length); - for (int i = 0; i < classNames.length; i++) { - out.writeUTF(classNames[i]); - } + writeStringArr(out, classNames); out.writeBoolean(instrSpawnedThreads); out.writeBoolean(startProfilingPointsActive); - out.writeObject(profilingPointIDs); - out.writeObject(profilingPointHandlers); - out.writeObject(profilingPointInfos); + + out.writeInt(profilingPointIDs.length); + for (int i = 0; i < profilingPointIDs.length; i++) { + out.writeInt(profilingPointIDs[i]); + + } + + writeStringArr(out, profilingPointHandlers); + writeStringArr(out, profilingPointInfos); + } + + private static void writeStringArr(DataOutputStream out, String[] arr) throws IOException { + out.writeInt(arr.length); + for (int i = 0; i < arr.length; i++) { + out.writeUTF(arr[i]); + } } + private static String[] readStringArr(DataInputStream in, boolean intern) throws IOException { + int len = in.readInt(); + String[] arr = new String[len]; + for (int i = 0; i < len; i++) { + String value = in.readUTF(); + if (intern) { + value = value.intern(); + } + arr[i] = value; + } + return arr; + } + } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupCommand.java index 79ee5f327305..040a7871209d 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -102,7 +104,7 @@ public String toString() { return "InstrumentMethodGroupCommand " + ((b != null) ? b.toString() : "null"); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { instrType = in.readInt(); if (!isEmpty()) { @@ -110,7 +112,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(instrType); if (!isEmpty()) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupData.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupData.java index d342254e3de0..7ee2d3391e3c 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupData.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupData.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -118,7 +120,7 @@ public String toString() { return ((instrMethodClasses != null) ? (instrMethodClasses.length) : 0) + " classes."; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { nClasses = in.readInt(); if (nClasses == 0) { @@ -167,7 +169,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { if (instrMethodClasses == null) { out.writeInt(0); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupResponse.java index 4883bef9bf17..eef246e390a8 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InstrumentMethodGroupResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -92,13 +94,13 @@ public String toString() { return "InstrumentMethodGroupResponse " + ((b != null) ? b.toString() : "empty"); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { if (!isEmpty()) { b.readObject(in); } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { if (!isEmpty()) { b.writeObject(out); } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InternalStatsResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InternalStatsResponse.java index a32a5873dc1f..6069dca05b5f 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InternalStatsResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/InternalStatsResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -69,7 +71,7 @@ public String toString() { return "InternalStatsResponse, " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { nTotalInstrMethods = in.readInt(); nClassLoads = in.readInt(); nFirstMethodInvocations = in.readInt(); @@ -88,7 +90,7 @@ void readObject(ObjectInputStream in) throws IOException { } // Custom serialization support - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(nTotalInstrMethods); out.writeInt(nClassLoads); out.writeInt(nFirstMethodInvocations); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodInvokedFirstTimeCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodInvokedFirstTimeCommand.java index dd0c958a8078..107a27644cf5 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodInvokedFirstTimeCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodInvokedFirstTimeCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -59,11 +61,11 @@ public String toString() { return super.toString() + ", methodId: " + ((int) methodId); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { methodId = in.readChar(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeChar(methodId); } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodLoadedCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodLoadedCommand.java index 7cdc5e2861b0..b2c9f930e5aa 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodLoadedCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodLoadedCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -110,14 +112,14 @@ public String toString() { + ", methodSignature: " + methodSignature; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { className = in.readUTF(); classLoaderId = in.readInt(); methodName = in.readUTF(); methodSignature = in.readUTF(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeUTF(className); out.writeInt(classLoaderId); out.writeUTF(methodName); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodNamesResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodNamesResponse.java index 022486aad1f9..020783c90e0c 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodNamesResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MethodNamesResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -61,7 +63,7 @@ public byte[] getPackedData() { return packedData; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int len = in.readInt(); packedData = new byte[len]; in.readFully(packedData); @@ -73,7 +75,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(packedData.length); out.write(packedData); out.writeInt(packedArrayOffsets.length); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MonitoredNumbersResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MonitoredNumbersResponse.java index 4aaaedfb847c..620055f69e75 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MonitoredNumbersResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/MonitoredNumbersResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -195,7 +197,7 @@ public String toString() { + ", serverProgress=" + serverProgress; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int arrSize; mode = in.readInt(); @@ -275,7 +277,7 @@ void readObject(ObjectInputStream in) throws IOException { serverProgress = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(mode); for (int i = 0; i < generalNumbers.length; i++) { out.writeLong(generalNumbers[i]); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ObjectAllocationResultsResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ObjectAllocationResultsResponse.java index fb7f66f7c183..8007c1ac5684 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ObjectAllocationResultsResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ObjectAllocationResultsResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -61,7 +63,7 @@ public String toString() { return "ObjectAllocationResultsResponse, entries: " + nEntries + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { nEntries = in.readInt(); results = new int[nEntries]; @@ -70,7 +72,7 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(nEntries); for (int i = 0; i < nEntries; i++) { diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Response.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Response.java index e5bd435ef375..879e94efd816 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Response.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/Response.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -121,7 +123,7 @@ void setYes(boolean yes) { this.yes = yes; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { } static String respTypeToString(int type) { @@ -165,6 +167,6 @@ static String respTypeToString(int type) { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/RootClassLoadedCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/RootClassLoadedCommand.java index 7b353ecaa56c..8fb40cbb9fbf 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/RootClassLoadedCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/RootClassLoadedCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -102,7 +104,7 @@ public String toString() { return "RootClassLoadedCommand, classes: " + classCount + ", " + super.toString(); // NOI18N } - void readObject(ObjectInputStream gin) throws IOException { + void readObject(DataInputStream gin) throws IOException { GZIPInputStream eix = new GZIPInputStream(gin, 32768); ObjectInputStream in = new ObjectInputStream(eix); byte[] EMPTY = new byte[0]; @@ -163,7 +165,7 @@ void readObject(ObjectInputStream gin) throws IOException { } } - void writeObject(ObjectOutputStream gout) throws IOException { + void writeObject(DataOutputStream gout) throws IOException { GZIPOutputStream eox = new GZIPOutputStream(gout, 32768); ObjectOutputStream out = new ObjectOutputStream(eox); out.writeInt(classCount); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetChangeableInstrParamsCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetChangeableInstrParamsCommand.java index a3688ef4eb97..08fc323b8ac6 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetChangeableInstrParamsCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetChangeableInstrParamsCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -134,7 +136,7 @@ public String toString() { + ", threadsSamplingFrequency: " + threadsSamplingFrequency; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { lockContentionMonitoringEnabled = in.readBoolean(); nProfiledThreadsLimit = in.readInt(); stackDepthLimit = in.readInt(); @@ -148,7 +150,7 @@ void readObject(ObjectInputStream in) throws IOException { threadsSamplingFrequency = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeBoolean(lockContentionMonitoringEnabled); out.writeInt(nProfiledThreadsLimit); out.writeInt(stackDepthLimit); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetUnchangeableInstrParamsCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetUnchangeableInstrParamsCommand.java index a074690d1016..98032fa6258c 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetUnchangeableInstrParamsCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/SetUnchangeableInstrParamsCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -88,7 +90,7 @@ public String toString() { + ", codeRegionCPUResBufSize: " + codeRegionCPUResBufSize; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { remoteProfiling = in.readBoolean(); absoluteTimerOn = in.readBoolean(); threadCPUTimerOn = in.readBoolean(); @@ -96,7 +98,7 @@ void readObject(ObjectInputStream in) throws IOException { codeRegionCPUResBufSize = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeBoolean(remoteProfiling); out.writeBoolean(absoluteTimerOn); out.writeBoolean(threadCPUTimerOn); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/TakeHeapDumpCommand.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/TakeHeapDumpCommand.java index dc2c618fb1a7..7b582dc4e461 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/TakeHeapDumpCommand.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/TakeHeapDumpCommand.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -56,11 +58,11 @@ public String toString() { return super.toString() + ", outputFile: " + outputFile; // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { outputFile = in.readUTF(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeUTF(outputFile); } } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadDumpResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadDumpResponse.java index d2725c548351..d1c0e470e922 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadDumpResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadDumpResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -61,7 +63,8 @@ public Object[] getThreads() { return cdThreads; } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream raw) throws IOException { + ObjectInputStream in = (ObjectInputStream) (Object) raw; jdk15 = in.readBoolean(); long t = in.readLong(); time = new Date(t); @@ -76,7 +79,8 @@ void readObject(ObjectInputStream in) throws IOException { } } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream raw) throws IOException { + ObjectOutputStream out = (ObjectOutputStream) (Object) raw; out.writeBoolean(jdk15); out.writeLong(time.getTime()); out.writeInt(cdThreads.length); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadLivenessStatusResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadLivenessStatusResponse.java index 91b79f39c704..90dab3cad761 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadLivenessStatusResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/ThreadLivenessStatusResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -58,13 +60,13 @@ public String toString() { return "ThreadLivenessStatusResponse, " + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { int len = in.readInt(); status = new byte[len]; in.readFully(status); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(status.length); out.write(status); } diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/VMPropertiesResponse.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/VMPropertiesResponse.java index a1c0dcd19174..b5a7f968a34e 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/VMPropertiesResponse.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/VMPropertiesResponse.java @@ -19,6 +19,8 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import org.netbeans.lib.profiler.global.CommonConstants; import java.io.IOException; import java.io.ObjectInputStream; @@ -156,7 +158,7 @@ public String toString() { + "\n" + super.toString(); // NOI18N } - void readObject(ObjectInputStream in) throws IOException { + void readObject(DataInputStream in) throws IOException { agentVersion = in.readInt(); jdkVersionString = in.readUTF(); javaClassPath = in.readUTF(); @@ -173,7 +175,7 @@ void readObject(ObjectInputStream in) throws IOException { agentId = in.readInt(); } - void writeObject(ObjectOutputStream out) throws IOException { + void writeObject(DataOutputStream out) throws IOException { out.writeInt(agentVersion); out.writeUTF(jdkVersionString); out.writeUTF(javaClassPath); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/WireIO.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/WireIO.java index 7b50876c71cf..2b0349d38ab8 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/WireIO.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/wireprotocol/WireIO.java @@ -19,9 +19,9 @@ package org.netbeans.lib.profiler.wireprotocol; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; /** @@ -47,13 +47,13 @@ public class WireIO { //~ Instance fields ---------------------------------------------------------------------------------------------------------- - private ObjectInputStream in; - private ObjectOutputStream out; + private DataInputStream in; + private DataOutputStream out; private long wasAlive; //~ Constructors ------------------------------------------------------------------------------------------------------------- - public WireIO(ObjectOutputStream pout, ObjectInputStream pin) { + public WireIO(DataOutputStream pout, DataInputStream pin) { out = pout; in = pin; } diff --git a/profiler/lib.profiler/test/qa-functional/src/org/netbeans/lib/profiler/tests/jfluid/wireio/CommonWireIOTestCase.java b/profiler/lib.profiler/test/qa-functional/src/org/netbeans/lib/profiler/tests/jfluid/wireio/CommonWireIOTestCase.java index 023f64759fb2..c43eaeeb4dc4 100644 --- a/profiler/lib.profiler/test/qa-functional/src/org/netbeans/lib/profiler/tests/jfluid/wireio/CommonWireIOTestCase.java +++ b/profiler/lib.profiler/test/qa-functional/src/org/netbeans/lib/profiler/tests/jfluid/wireio/CommonWireIOTestCase.java @@ -23,8 +23,8 @@ import org.netbeans.lib.profiler.wireprotocol.Command; import org.netbeans.lib.profiler.wireprotocol.WireIO; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.net.ServerSocket; import java.net.Socket; @@ -94,8 +94,8 @@ public WireIO createWireIO(Socket clientSocket) { try { clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - ObjectInputStream socketIn = new ObjectInputStream(clientSocket.getInputStream()); - ObjectOutputStream socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); + DataInputStream socketIn = new DataInputStream(clientSocket.getInputStream()); + DataOutputStream socketOut = new DataOutputStream(clientSocket.getOutputStream()); WireIO wireIO = new WireIO(socketOut, socketIn); return wireIO; @@ -111,8 +111,8 @@ public WireIO createWireIOClient(Socket clientSocket) { clientSocket.setSoTimeout(0); clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - ObjectOutputStream socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); - ObjectInputStream socketIn = new ObjectInputStream(clientSocket.getInputStream()); + DataOutputStream socketOut = new DataOutputStream(clientSocket.getOutputStream()); + DataInputStream socketIn = new DataInputStream(clientSocket.getInputStream()); WireIO wireIO = new WireIO(socketOut, socketIn); return wireIO; From 690669283752c46d386151efc9619abc38f86504 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sat, 21 Nov 2026 08:31:48 +0100 Subject: [PATCH 2/2] Use Data*Stream in profiler/profiler as well --- .../modules/profiler/NetBeansProfiler.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/profiler/profiler/src/org/netbeans/modules/profiler/NetBeansProfiler.java b/profiler/profiler/src/org/netbeans/modules/profiler/NetBeansProfiler.java index 5b56505be094..9000f80b94da 100644 --- a/profiler/profiler/src/org/netbeans/modules/profiler/NetBeansProfiler.java +++ b/profiler/profiler/src/org/netbeans/modules/profiler/NetBeansProfiler.java @@ -34,11 +34,11 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.net.Socket; import java.net.SocketTimeoutException; import java.util.Collection; @@ -1434,15 +1434,15 @@ public boolean shutdownBlockedAgent(String host, int port, int agentId) { if (state == CommonConstants.AGENT_STATE_READY_DIRECT) { Socket clientSocket = null; - ObjectOutputStream socketOut = null; - ObjectInputStream socketIn = null; + DataOutputStream socketOut = null; + DataInputStream socketIn = null; try { clientSocket = new Socket(host, port); clientSocket.setSoTimeout(100); clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); - socketIn = new ObjectInputStream(clientSocket.getInputStream()); + socketOut = new DataOutputStream(clientSocket.getOutputStream()); + socketIn = new DataInputStream(clientSocket.getInputStream()); WireIO wio = new WireIO(socketOut, socketIn); wio.sendSimpleCommand(Command.TERMINATE_TARGET_JVM); @@ -1840,15 +1840,15 @@ private boolean shutdownAgent(String host, int port) { if (port == -1) return false; // invalid port Socket clientSocket = null; - ObjectOutputStream socketOut = null; - ObjectInputStream socketIn = null; + DataOutputStream socketOut = null; + DataInputStream socketIn = null; try { clientSocket = new Socket(host, port); clientSocket.setSoTimeout(100); clientSocket.setTcpNoDelay(true); // Necessary at least on Solaris to avoid delays in e.g. readInt() etc. - socketOut = new ObjectOutputStream(clientSocket.getOutputStream()); - socketIn = new ObjectInputStream(clientSocket.getInputStream()); + socketOut = new DataOutputStream(clientSocket.getOutputStream()); + socketIn = new DataInputStream(clientSocket.getInputStream()); WireIO wio = new WireIO(socketOut, socketIn); wio.sendSimpleCommand(Command.TERMINATE_TARGET_JVM);