JDK-8253961 : Add @ValueBased to Panama Foreign API
  • Type: Sub-task
  • Component: tools
  • Sub-Component: jextract
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2020-10-02
  • Updated: 2020-11-19
  • Resolved: 2020-11-19
Related Reports
Blocks :  
Description
Add @ValueBased to the value-based classes in the jdk.incubator.foreign module.
Comments
My suggestion is to remove this from JEP390 scope. The Panama team can adapt the APIs and implementation at their convenience to the new definition of ValueBased.
19-11-2020

This is true, but only because we use an intermediate abstract class (AbstractLayout) which declares a couple of fields. AbstractLayout is NOT a public class, and is impl only. So we can refactor that code at will. What about interfaces? We'd like to be able to say that implementation of MemoryAddress and MemorySegment should be value-based - how do we do that?
19-11-2020

(Most) Panama Foreign public classes do not meet the criteria for ValueBased: jdk.incubator.foreign.AbstractLayout NOT @ValueBased: is abstract and has fields jdk.incubator.foreign.GroupLayout NOT @ValueBased: superclass has non-trivial constructors; superclass has fields jdk.incubator.foreign.PaddingLayout NOT @ValueBased: superclass has non-trivial constructors; superclass has fields jdk.incubator.foreign.SequenceLayout NOT @ValueBased: superclass has non-trivial constructors; superclass has fields jdk.incubator.foreign.ValueLayout NOT @ValueBased: superclass has non-trivial constructors; superclass has fields jdk.incubator.foreign.MappedMemorySegment NOT @ValueBased: is an interface jdk.incubator.foreign.MemoryAddress NOT @ValueBased: is an interface jdk.incubator.foreign.MemoryLayout NOT @ValueBased: is an interface jdk.incubator.foreign.MemoryLayout$PathElement NOT @ValueBased: is an interface jdk.incubator.foreign.MemorySegment NOT @ValueBased: is an interface Only 2 classes meet the criteria: jdk.incubator.foreign.MemoryHandles jdk.incubator.foreign.MemoryLayouts The API is in an incubator package and does not have access to the jdk.internal.ValueBased annotation (without a special export).
19-11-2020

Classes or interfaces that talk about value-based classes: ./share/classes/jdk/incubator/foreign/ValueLayout.java: * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a> ./share/classes/jdk/incubator/foreign/GroupLayout.java: * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a> ./share/classes/jdk/incubator/foreign/MemoryLayout.java: * All implementations of this interface must be <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>; ./share/classes/jdk/incubator/foreign/MemoryLayout.java: * Implementations of this interface are immutable, thread-safe and <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>. ./share/classes/jdk/incubator/foreign/MemoryAddress.java: * All implementations of this interface must be <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>; ./share/classes/jdk/incubator/foreign/MemoryAddress.java: * Implementations of this interface are immutable, thread-safe and <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>. ./share/classes/jdk/incubator/foreign/PaddingLayout.java: * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a> ./share/classes/jdk/incubator/foreign/Addressable.java: * Implementations of this interface <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>. ./share/classes/jdk/incubator/foreign/MemorySegment.java: * All implementations of this interface must be <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>; ./share/classes/jdk/incubator/foreign/MemorySegment.java: * Implementations of this interface are immutable, thread-safe and <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>. ./share/classes/jdk/incubator/foreign/SequenceLayout.java: * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
19-11-2020