81 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
81 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
82 */ |
82 */ |
83 |
83 |
84 package jdk.internal.dynalink.linker; |
84 package jdk.internal.dynalink.linker; |
85 |
85 |
|
86 |
86 /** |
87 /** |
87 * Guarded type conversion |
88 * A tuple of a {@link GuardedInvocation} describing a conditional type |
|
89 * conversion and a boolean flag indicating whether the result is allowed to |
|
90 * be cached. While most type conversions are cacheable, some can have security |
|
91 * implications. An example is converting e.g. function objects from the source |
|
92 * language into implementations of Java functional interface objects, with |
|
93 * adapter classes for those interfaces being created on the fly and being |
|
94 * sensitive to the protection domain of their creator. Such converter |
|
95 * invocation must be marked as non-cacheable so that Dynalink will know not to |
|
96 * keep and reuse them in different contexts. |
88 */ |
97 */ |
89 public class GuardedTypeConversion { |
98 public class GuardedTypeConversion { |
90 private final GuardedInvocation conversionInvocation; |
99 private final GuardedInvocation conversionInvocation; |
91 private final boolean cacheable; |
100 private final boolean cacheable; |
92 |
101 |
93 /** |
102 /** |
94 * Constructor |
103 * Creates a new guarded type conversion. |
95 * @param conversionInvocation guarded invocation for this type conversion |
104 * @param conversionInvocation guarded invocation implementing this type |
96 * @param cacheable is this invocation cacheable |
105 * conversion. |
|
106 * @param cacheable true if this invocation is cacheable, false otherwise. |
97 */ |
107 */ |
98 public GuardedTypeConversion(final GuardedInvocation conversionInvocation, final boolean cacheable) { |
108 public GuardedTypeConversion(final GuardedInvocation conversionInvocation, final boolean cacheable) { |
99 this.conversionInvocation = conversionInvocation; |
109 this.conversionInvocation = conversionInvocation; |
100 this.cacheable = cacheable; |
110 this.cacheable = cacheable; |
101 } |
111 } |
102 |
112 |
103 /** |
113 /** |
104 * Get the invocation |
114 * Returns the invocation implementing the type conversion. |
105 * @return invocation |
115 * @return the invocation implementing the type conversion. |
106 */ |
116 */ |
107 public GuardedInvocation getConversionInvocation() { |
117 public GuardedInvocation getConversionInvocation() { |
108 return conversionInvocation; |
118 return conversionInvocation; |
109 } |
119 } |
110 |
120 |
111 /** |
121 /** |
112 * Check if invocation is cacheable |
122 * Returns true if this conversion is allowed to be cached and reused by |
113 * @return true if cacheable, false otherwise |
123 * Dynalink. |
|
124 * @return true if this conversion is allowed to be cached and reused by |
|
125 * Dynalink. |
114 */ |
126 */ |
115 public boolean isCacheable() { |
127 public boolean isCacheable() { |
116 return cacheable; |
128 return cacheable; |
117 } |
129 } |
118 } |
130 } |