From c743f69f8f19a03ae1a7006aa7cbbf2d26062cd4 Mon Sep 17 00:00:00 2001 From: Stephanie Gawroriski Date: Tue, 23 Jan 2024 23:58:00 +0000 Subject: [PATCH] Add read of ID that uses kinds. --- .../main/java/cc/squirreljme/jdwp/JDWPPacket.java | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/debug-jdwp/src/main/java/cc/squirreljme/jdwp/JDWPPacket.java b/modules/debug-jdwp/src/main/java/cc/squirreljme/jdwp/JDWPPacket.java index 5dbb4b71d3..9b4cfc3ae1 100644 --- a/modules/debug-jdwp/src/main/java/cc/squirreljme/jdwp/JDWPPacket.java +++ b/modules/debug-jdwp/src/main/java/cc/squirreljme/jdwp/JDWPPacket.java @@ -423,20 +423,35 @@ public final class JDWPPacket } /** - * Reads an ID of the given kind. + * Reads the ID based on the kind from the packet. * - * @param __kind The kind of ID to read. - * @return The read ID. + * @param __kind The kind of value to read. + * @return The resultant ID. + * @throws JDWPException If the kind is not valid or ID sizes are not yet + * known. * @throws NullPointerException On null arguments. - * @since 2024/01/22 + * @since 2024/01/23 */ - public final JDWPId readId(JDWPIdKind __kind) - throws NullPointerException + public JDWPId readId(JDWPIdKind __kind) + throws JDWPException, NullPointerException { if (__kind == null) throw new NullPointerException("NARG"); - return JDWPId.of(__kind, this.readId()); + synchronized (this) + { + // Ensure this is open + this.__checkOpen(); + + /* {@squirreljme.error AG0z ID Sizes not currently known.} */ + JDWPIdSizes idSizes = this._idSizes; + if (idSizes == null) + throw new JDWPException("AG0z"); + + /* Read in the variably sized entry. */ + return JDWPId.of(__kind, + this.readVariable(idSizes.getSize(__kind))); + } } /** -- 2.11.4.GIT