From markro at cs.washington.edu Thu Jul 10 22:32:52 2025 From: markro at cs.washington.edu (Mark Roberts) Date: Thu, 10 Jul 2025 15:32:52 -0700 Subject: How build an abstract method? Message-ID: <3a3a5b191c6dcdde87ac7816a6b52e65@mail.gmail.com> MethodBuilder.withCode won?t allow 0 length body. Don?t see how to create an abstract method and define its parameters. Thank you, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From chen.l.liang at oracle.com Thu Jul 10 22:46:19 2025 From: chen.l.liang at oracle.com (Chen Liang) Date: Thu, 10 Jul 2025 22:46:19 +0000 Subject: [External] : How build an abstract method? In-Reply-To: <3a3a5b191c6dcdde87ac7816a6b52e65@mail.gmail.com> References: <3a3a5b191c6dcdde87ac7816a6b52e65@mail.gmail.com> Message-ID: An abstract method does not have code. You shouldn't be calling withCode, which always generates a Code attribute, which is exactly what you don't want. If you are calling from ClassBuilder, call withMethod instead of withMethodBody. Chen ________________________________ From: Mark Roberts Sent: Thursday, July 10, 2025 5:32 PM To: classfile-api-dev at openjdk.org Cc: Chen Liang Subject: [External] : How build an abstract method? MethodBuilder.withCode won?t allow 0 length body. Don?t see how to create an abstract method and define its parameters. Thank you, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From markro at cs.washington.edu Thu Jul 10 22:52:04 2025 From: markro at cs.washington.edu (Mark Roberts) Date: Thu, 10 Jul 2025 15:52:04 -0700 Subject: [External] : How build an abstract method? In-Reply-To: References: <3a3a5b191c6dcdde87ac7816a6b52e65@mail.gmail.com> Message-ID: That?s what I?m doing. My problem must be I?m using the wrong thing for the MethodBuilder handler argument. What do you suggest? *From:* Chen Liang *Sent:* Thursday, July 10, 2025 3:46 PM *To:* Mark Roberts ; classfile-api-dev at openjdk.org *Subject:* Re: [External] : How build an abstract method? An abstract method does not have code. You shouldn't be calling withCode, which always generates a Code attribute, which is exactly what you don't want. If you are calling from ClassBuilder, call withMethod instead of withMethodBody. Chen ------------------------------ *From:* Mark Roberts *Sent:* Thursday, July 10, 2025 5:32 PM *To:* classfile-api-dev at openjdk.org *Cc:* Chen Liang *Subject:* [External] : How build an abstract method? MethodBuilder.withCode won?t allow 0 length body. Don?t see how to create an abstract method and define its parameters. Thank you, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From chen.l.liang at oracle.com Thu Jul 10 22:54:06 2025 From: chen.l.liang at oracle.com (Chen Liang) Date: Thu, 10 Jul 2025 22:54:06 +0000 Subject: Stricter number size checks in the Class-File API Message-ID: The Class-File API currently has a lot of places where it takes u2 or u1 arguments as int. However, these arguments are never validated that they are actually read back to the same int value after truncation that happens when writing to class files. These usually represent user errors that should be corrected. In particular, list structures in the class file format use u2 or u1 for their sizes. When list sizes are truncated, it directly leads to malformed class files, which is a more serious problem that is also harder to diagnose sometimes. As a result, I am proposing to check these out-of-range values (except for accepting -1 as the class file minor version for 65535) eagerly whenever possible - that is, when passed to construct API models. I expect relatively low compatibility impact, as these out-of-range values usually do not appear when judged case-by-case. Users can fallback to explicit argument truncation before passing the arguments as well. See the CSRs for details: https://bugs.openjdk.org/browse/JDK-8361637 https://bugs.openjdk.org/browse/JDK-8361906 Please do not hesitate to disagree with this assessment if you have any reason, for example, one of these "erroneous" usages are actually meaningful in your particular workload. Regards, Chen Liang -------------- next part -------------- An HTML attachment was scrubbed... URL: