[code-reflection] RFR: Improved error message if Reflect annotation is missing on transitive methods from kernel method [v3]

Nadeesh TV ntv at openjdk.org
Fri Jan 2 21:18:16 UTC 2026


> **Description** 
> Currently, if we miss the **@Reflec**t annotation on methods called from kernel functions, no method is generated for them in the corresponding backend. This causes an error like:
> 
> `> error: implicit declaration of function 'squareitWithoutReflectAnnotation' is invalid...
> `
> **Solution** 
> - Improved the error message by adding:  *"Did you miss @Reflect annotation on the above function?"* for such cases.
> 
>    - Tried throwing an early error on the Java side, but calls to certain methods (e.g., `hat.buffer.S32Array.length()`) lack @Reflect annotations yet map to native functions later. Therefore, I could not find an easy early Java-side validation.
> 
> **Test** 
>   -  A new test is added at **hat.test.TestMissingReflectAnnotation#testTransitiveMethoFromKernelWithoutReflectAnnotation**
>   - Output of the test case
> 
> UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed
> buildStatus = failed
> logLen = 234 log  = program_source:68:37: error: implicit declaration of function 'squareitWithoutReflectAnnotation' is invalid in OpenCL
>         array->array[(long)HAT_GIX]=squareitWithoutReflectAnnotation(value);
>                                     ^
> 
> Did you miss @Reflect annotation on the above function?
> 
> Class: hat.test.TestMissingReflectAnnotation
> Testing: #testComputeMethodWithoutReflectAnnotation..................... [passed]
> Testing: #testKernelMethodWithoutReflectAnnotation..................... [passed]
> Testing: #testTransitiveMethoFromKernelWithoutReflectAnnotation..................... [passed]
> 
> passed: 3, failed: 0, unsupported: 0, precision-errors: 0

Nadeesh TV has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 11 additional commits since the last revision:

 - Merge branch 'code-reflection' into verify_reflect_annotation_part2_retry
 - Move the Reflect annoation verification to java
 - Removed previous transformer patter experiments
 - More FP16Phase cleanup. Leveraging Invoke helper
 - Unreflect tests
 - fix of TestJavaVersionCheckerForLambdas and TestJavaVersionCheckerForMethods
 - Cleanup of FP16Phase removing duplicate code and leaning on InvokHelper
 - Migrated BufferTagger to use InvokeOpHelper for common tasks
 - Unified access type info.. also removed dead optkl.Trxfmr  code
 - Removed extra whitespace
 - ... and 1 more: https://git.openjdk.org/babylon/compare/f3930b21...f6b6bfde

-------------

Changes:
  - all: https://git.openjdk.org/babylon/pull/798/files
  - new: https://git.openjdk.org/babylon/pull/798/files/20a3bad0..f6b6bfde

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=babylon&pr=798&range=02
 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=798&range=01-02

  Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/babylon/pull/798.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/798/head:pull/798

PR: https://git.openjdk.org/babylon/pull/798


More information about the babylon-dev mailing list