• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yahoo / elide / #7464

06 Dec 2025 12:01AM UTC coverage: 84.293% (-0.1%) from 84.409%
#7464

push

justin-tay
Update to Spring Boot 3.5.8 and align dependencies

0 of 51 new or added lines in 3 files covered. (0.0%)

3 existing lines in 2 files now uncovered.

19744 of 23423 relevant lines covered (84.29%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/elide-core/src/main/java/com/yahoo/elide/core/graal/ElideFeature.java
1
/*
2
 * Copyright 2023, the original author or authors.
3
 * Licensed under the Apache License, Version 2.0
4
 * See LICENSE file in project root for terms.
5
 */
6
package com.yahoo.elide.core.graal;
7

8
import com.yahoo.elide.annotation.LifeCycleHookBinding;
9
import com.yahoo.elide.core.utils.ClassScannerCache;
10

11
import org.graalvm.nativeimage.hosted.Feature;
12
import org.graalvm.nativeimage.hosted.RuntimeReflection;
13

14
import io.github.classgraph.ClassGraph;
15
import io.github.classgraph.ClassInfo;
16
import io.github.classgraph.ScanResult;
17

18
import java.lang.reflect.Constructor;
19
import java.lang.reflect.Field;
20
import java.lang.reflect.Method;
21
import java.util.ArrayList;
22
import java.util.LinkedHashSet;
23
import java.util.List;
24
import java.util.Map;
25
import java.util.Set;
26
import java.util.stream.Collectors;
27

28
/**
29
 * Native Image Feature for Elide.
30
 */
31
public class ElideFeature implements Feature {
×
32
    @Override
33
    public void beforeAnalysis(BeforeAnalysisAccess access) {
NEW
34
        Map<String, Set<Class<?>>> classes = ClassScannerCache.getInstance();
×
35
        // In GraalVM 21+ java.class.path is not set so need to use
36
        // access.getApplicationClassPath otherwise no classes are found
NEW
37
        try (ScanResult scanResult = new ClassGraph().overrideClasspath(access.getApplicationClassPath())
×
NEW
38
                .enableClassInfo().enableAnnotationInfo().scan()) {
×
NEW
39
            for (String annotationName : ClassScannerCache.getCachedAnnotations()) {
×
NEW
40
                Set<Class<?>> value = scanResult.getClassesWithAnnotation(annotationName).stream()
×
NEW
41
                        .map(ClassInfo::loadClass).collect(Collectors.toCollection(LinkedHashSet::new));
×
NEW
42
                if (!value.isEmpty()) {
×
NEW
43
                    classes.put(annotationName, value);
×
44
                }
45
            }
46
        }
NEW
47
        Set<Class<?>> results = new LinkedHashSet<>();
×
NEW
48
        classes.values().stream().forEach(set -> set.stream().forEach(clazz -> {
×
NEW
49
            results.add(clazz);
×
NEW
50
            LifeCycleHookBinding lifeCycleHookBinding = clazz.getAnnotation(LifeCycleHookBinding.class);
×
NEW
51
            if (lifeCycleHookBinding != null) {
×
NEW
52
                results.add(lifeCycleHookBinding.hook());
×
53
            }
NEW
54
        }));
×
NEW
55
        Set<Class<?>> hooks = new LinkedHashSet<>();
×
NEW
56
        results.forEach(clazz -> {
×
57
            for (Field field : clazz.getFields()) {
×
NEW
58
                LifeCycleHookBinding lifeCycleHookBinding = field.getAnnotation(LifeCycleHookBinding.class);
×
NEW
59
                if (lifeCycleHookBinding != null) {
×
NEW
60
                    hooks.add(lifeCycleHookBinding.hook());
×
61
                }
62
            }
UNCOV
63
            for (Method method : clazz.getMethods()) {
×
NEW
64
                LifeCycleHookBinding lifeCycleHookBinding = method.getAnnotation(LifeCycleHookBinding.class);
×
NEW
65
                if (lifeCycleHookBinding != null) {
×
NEW
66
                    hooks.add(lifeCycleHookBinding.hook());
×
67
                }
68
            }
NEW
69
        });
×
NEW
70
        results.addAll(hooks);
×
71
        // Sort
NEW
72
        List<Class<?>> ordered = new ArrayList<>(results);
×
NEW
73
        ordered.sort((left, right) -> {
×
NEW
74
            return left.getName().compareTo(right.getName());
×
75
        });
NEW
76
        ordered.forEach(this::register);
×
NEW
77
    }
×
78

79
    void register(Class<?> clazz) {
NEW
80
        System.out.println("Elide registering " + clazz + " for reflection");
×
81

NEW
82
        RuntimeReflection.register(clazz);
×
NEW
83
        for (Field field : clazz.getFields()) {
×
NEW
84
            RuntimeReflection.register(field);
×
85
        }
86

NEW
87
        for (Method method : clazz.getMethods()) {
×
NEW
88
            RuntimeReflection.register(method);
×
89
        }
90

NEW
91
        for (Constructor<?> constructor : clazz.getConstructors()) {
×
NEW
92
            RuntimeReflection.register(constructor);
×
93
        }
94

NEW
95
        for (Field field : clazz.getDeclaredFields()) {
×
NEW
96
            RuntimeReflection.register(field);
×
97
        }
98

NEW
99
        for (Method method : clazz.getDeclaredMethods()) {
×
NEW
100
            RuntimeReflection.register(method);
×
101
        }
102

NEW
103
        for (Constructor<?> constructor : clazz.getDeclaredConstructors()) {
×
NEW
104
            RuntimeReflection.register(constructor);
×
105
        }
UNCOV
106
    }
×
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc