Skip to content

fix bytecode attributes for patched files#24180

Closed
hamzaremmal wants to merge 1 commit intoscala:mainfrom
hamzaremmal:i24161
Closed

fix bytecode attributes for patched files#24180
hamzaremmal wants to merge 1 commit intoscala:mainfrom
hamzaremmal:i24161

Conversation

@hamzaremmal
Copy link
Copy Markdown
Member

@hamzaremmal hamzaremmal commented Oct 15, 2025

We should probably add a TASTY attribute in the bytecode too but as a first glance, it looks very annoying to compute in the plugin.

Closes #24161

@hamzaremmal hamzaremmal marked this pull request as ready for review October 15, 2025 04:43
@hamzaremmal hamzaremmal requested a review from sjrd October 15, 2025 04:44
@som-snytt
Copy link
Copy Markdown
Contributor

you intend to link 24161

@hamzaremmal
Copy link
Copy Markdown
Member Author

you intend to link 24161

Indeed, thanks for catching this

@sjrd
Copy link
Copy Markdown
Member

sjrd commented Oct 15, 2025

The CI is not happy:

java.lang.IllegalArgumentException: Unsupported class file major version 12590

Copy link
Copy Markdown
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

as a first glance, it looks very annoying to compute in the plugin.

Is it? Since we can assume the .tasty file is well-formed and compiled by our version of the compiler, it should be rather straightforward:

  1. Skip 4x4 = 16 bytes (magic number, major v, minor v, experimental v)
  2. Read 4 bytes as toolVersionLength
  3. Skip toolVersionLength bytes
  4. Read 16 bytes as uuidBytes

}

/* Remove Scala 2 Pickles from Classfiles */
private def unpickler(bytes: Array[Byte]): Array[Byte] = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a very confusing name, as the "unpickler" in the compiler is the thing that actually decodes things. Consider

Suggested change
private def unpickler(bytes: Array[Byte]): Array[Byte] = {
private def removeScala2Pickles(bytes: Array[Byte]): Array[Byte] = {

@WojciechMazur WojciechMazur added this to the 3.8.0 milestone Nov 4, 2025
@Gedochao
Copy link
Copy Markdown
Contributor

@hamzaremmal do we need this in 3.8.0? this feels potentially overdue

@Gedochao
Copy link
Copy Markdown
Contributor

@sjrd do you know where this stands? is this necessary for 3.8.0?

WojciechMazur added a commit that referenced this pull request Jan 7, 2026
…r copied stdlib .class files (#24846)

Fixes #24161 
Based on and superseeds #24180 

We're now actively removing Scala 2 pickle annotations and emit
synthetic TASTY attributes (for primary classes). Both of validations
are now checked at build time
@WojciechMazur
Copy link
Copy Markdown
Contributor

Changes were included in #24846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

actively remove the pickle annotations when "copying" the class files over from Scala 2

5 participants