aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/jvm/reflection.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/target/jvm/reflection.lux')
-rw-r--r--stdlib/source/lux/target/jvm/reflection.lux19
1 files changed, 16 insertions, 3 deletions
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index 6305e361f..bb0a388e9 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -66,11 +66,16 @@
(#static isInterface [int] boolean)
(#static isAbstract [int] boolean)])
+(import: java/lang/annotation/Annotation)
+
+(import: java/lang/Deprecated)
+
(import: java/lang/reflect/Field
["#::."
(getDeclaringClass [] (java/lang/Class java/lang/Object))
(getModifiers [] int)
- (getGenericType [] java/lang/reflect/Type)])
+ (getGenericType [] java/lang/reflect/Type)
+ (getDeclaredAnnotations [] [java/lang/annotation/Annotation])])
(import: java/lang/reflect/Method
["#::."
@@ -350,9 +355,16 @@
(#try.Failure _)
(exception.throw ..unknown_field [field target])))
+(def: #export deprecated?
+ (-> (array.Array java/lang/annotation/Annotation) Bit)
+ (|>> array.to_list
+ (list.all (|>> (host.check java/lang/Deprecated)))
+ list.empty?
+ not))
+
(template [<name> <exception> <then?> <else?>]
[(def: #export (<name> field class)
- (-> Text (java/lang/Class java/lang/Object) (Try [Bit (/.Type Value)]))
+ (-> Text (java/lang/Class java/lang/Object) (Try [Bit Bit (/.Type Value)]))
(do {! try.monad}
[fieldJ (..field field class)
#let [modifiers (java/lang/reflect/Field::getModifiers fieldJ)]]
@@ -360,7 +372,8 @@
<then?> (|> fieldJ
java/lang/reflect/Field::getGenericType
..type
- (\ ! map (|>> [(java/lang/reflect/Modifier::isFinal modifiers)])))
+ (\ ! map (|>> [(java/lang/reflect/Modifier::isFinal modifiers)
+ (..deprecated? (java/lang/reflect/Field::getDeclaredAnnotations fieldJ))])))
<else?> (exception.throw <exception> [field class]))))]
[static_field ..not_a_static_field #1 #0]