Skip to content

Enhance D2D pipeline to identify generated code #1900 - #2216

Open
chinyeungli wants to merge 1 commit into
mainfrom
1900_d2d_flag_generated_code
Open

Enhance D2D pipeline to identify generated code #1900#2216
chinyeungli wants to merge 1 commit into
mainfrom
1900_d2d_flag_generated_code

Conversation

@chinyeungli

Copy link
Copy Markdown
Contributor
  • Add code to identify generated code based on path patterns or bytecode markers
  • Update status flag for identified generated files
  • Update extra_data field for reason the file is identifed as generated

Issues

Changes

This PR enhances the D2D pipeline to support generated code.

Non-Java Code

The current D2D pipeline already has options to handle Groovy, Scala, Kotlin, etc.
Further enhancements are tracked in:
#1875
#1993
#2214

Generated Code with Sources

For the scenarios described in #1900, all generated sources (from XSD or other tools) or enhanced bytecode should have corresponding .java files generated. The current technique of file basename/path matching and mapping should handle D2D processing without issue.

Generated Code without Sources

This leaves cases where binary (.class) files are compiled from generated sources during build time, but those generated sources are not packaged in the final source package. In these scenarios, .class files exist without corresponding .java files.

To address this, we use bytecode markers to identify if .class files were compiled from generated sources. The code uses the read_bytes() function to read the raw bytes and search for markers indicating generated source code.

Additionally, path patterns are used to identify generated sources.

Sample:

~/tmp/xsd-generated-code$ find . -type f
./target/maven-archiver/pom.properties
./target/xsd-generated-code-1.0.0.jar
./target/classes/META-INF/JAXB/episode_default.xjb
./target/classes/com/example/generated/package-info.class
./target/classes/com/example/generated/ObjectFactory.class
./target/classes/com/example/generated/Person.class
./target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
./target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
./target/generated-sources/jaxb/META-INF/JAXB/episode_default.xjb
./target/generated-sources/jaxb/com/example/generated/ObjectFactory.java
./target/generated-sources/jaxb/com/example/generated/Person.java
./target/generated-sources/jaxb/com/example/generated/package-info.java
./target/xsd-generated-code-1.0.0-sources.jar
./target/jaxb2/.default-xjcStaleFlag
./pom.xml
./src/main/xsd/schema.xsd

Identified generated file status
Screenshot 2026-08-27 154146

Reason of why it's identified as generated file
Screenshot 2026-08-27 154155

Checklist

  • I have read the contributing guidelines
  • I have linked an existing issue above
  • I have added unit tests covering the new code
  • I have reviewed and understood every line of this PR

 * Add code to identify generated code based on path patterns or bytecode markers
 * Update status flag for identified generated files
 * Update extra_data field for reason the file is identifed as generated

Signed-off-by: Chin Yeung Li <tli@nexb.com>
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.

JVM d2d: Improve d2d pipeline to support generated code and more

1 participant