Skip to content

8358772: Template-Framework Library: Primitive Types #25672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

eme64
Copy link
Contributor

@eme64 eme64 commented Jun 6, 2025

I would like to add primitive type support to the template framework library.

In follow-up work, we will use these types in random expression generation - but they can also already be useful on their own now.

I encountered an issue with some methods that return Token from the TemplateFramework, such as Hook.insert and addDataName. Since Token was package private, this class could not be used in some places where automatic type inference is required. I now refactored the code, so that the Token is just an empty interface, and all the methods are moved to a separate class TokenParser.

Original experiments from here: #23418


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8358772: Template-Framework Library: Primitive Types (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25672/head:pull/25672
$ git checkout pull/25672

Update a local copy of the PR:
$ git checkout pull/25672
$ git pull https://git.openjdk.org/jdk.git pull/25672/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25672

View PR using the GUI difftool:
$ git pr show -t 25672

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25672.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 6, 2025

👋 Welcome back epeter! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 6, 2025

@eme64 This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot changed the title JDK-8358772 8358772: Template-Framework Library: Primitive Types, Operations and Expressions Jun 6, 2025
@openjdk
Copy link

openjdk bot commented Jun 6, 2025

@eme64 The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@eme64 eme64 changed the title 8358772: Template-Framework Library: Primitive Types, Operations and Expressions 8358772: Template-Framework Library: Primitive Types Jun 12, 2025
@eme64 eme64 marked this pull request as ready for review June 12, 2025 10:24
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 12, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 12, 2025

Webrevs

Copy link
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another great addition to the Template Framework! Thank you for your continued effort, @eme64.

The broad strokes look good to me, but I have some remarks about a few details.


@Override
public boolean isSubtypeOf(DataName.Type other) {
return (other instanceof PrimitiveType pt) && pt.kind == kind;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be useful to implement the primitive type subtyping rules from JLS §4.10.1. I can imagine that it might help generating more diverse programs with random variables of random primitive types. That might help with fuzzing IGVN optimizations on ranges?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice idea :)
I'll file a separate RFE for this. It is not a prime feature I need now, but it would be a good extension.
The user can still get exact behavior with exactOf, but also subtype behavior with subtypeOf. Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed: JDK-8359335

Comment on lines +63 to +73
// Create a new CompileFramework instance.
CompileFramework comp = new CompileFramework();

// Add a java source file.
comp.addJavaSourceCode("p.xyz.InnerTest", generate());

// Compile the source file.
comp.compile();

// p.xyz.InnerTest.main();
comp.invoke("p.xyz.InnerTest", "main", new Object[] {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would remove the comments here, since this is not a tutorial about the compile framework and the code is self-explanatory (the methods match the comments pretty well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still an example, so I'll leave it. It doesn't hurt. But I may drop them in the future :)

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice additions to the library! Lot of minor comments, otherwise, looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 12, 2025
Co-authored-by: Christian Hagedorn <[email protected]>
Co-authored-by: Manuel Hässig <[email protected]>
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 12, 2025
eme64 and others added 2 commits June 12, 2025 11:15
Co-authored-by: Christian Hagedorn <[email protected]>
Co-authored-by: Manuel Hässig <[email protected]>
@eme64
Copy link
Contributor Author

eme64 commented Jun 12, 2025

@chhagedorn @mhaessig Thanks for the extremely quick reviews and the good suggestions. I addressed them all :)


/**
* List of all {@link PrimitiveType}s.
*/
public static final List<PrimitiveType> PRIMITIVE_TYPES = List.of(
static final List<PrimitiveType> PRIMITIVE_TYPES = List.of(
Copy link
Member

@chhagedorn chhagedorn Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static final can also be removed for constants :-) Otherwise, looks good, thanks for the update!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 12, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 12, 2025
@eme64 eme64 requested review from chhagedorn and mhaessig June 12, 2025 11:39
Copy link
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing our comments so quickly. Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants