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

hazendaz / jmockit1 / 496

15 Nov 2025 05:33PM UTC coverage: 72.192% (-0.008%) from 72.2%
496

push

github

web-flow
Merge pull request #412 from hazendaz/renovate/major-spring-core

Update spring core to v7 (major)

5677 of 8360 branches covered (67.91%)

Branch coverage included in aggregate %.

11922 of 16018 relevant lines covered (74.43%)

0.74 hits per line

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

90.38
/main/src/main/java/mockit/asm/AnnotatedReader.java
1
/*
2
 * MIT License
3
 * Copyright (c) 2006-2025 JMockit developers
4
 * See LICENSE file for full license text.
5
 */
6
package mockit.asm;
7

8
import edu.umd.cs.findbugs.annotations.NonNull;
9
import edu.umd.cs.findbugs.annotations.Nullable;
10

11
import mockit.asm.annotations.AnnotationReader;
12
import mockit.asm.annotations.AnnotationVisitor;
13
import mockit.asm.jvmConstants.Access;
14
import mockit.asm.util.BytecodeReader;
15

16
import org.checkerframework.checker.index.qual.NonNegative;
17

18
/**
19
 * A bytecode reader for reading common elements (signature, annotations) of a class, field, or method.
20
 */
21
public abstract class AnnotatedReader extends BytecodeReader {
22
    @NonNull
1✔
23
    private final AnnotationReader annotationReader = new AnnotationReader(this);
24

25
    @NonNegative
26
    private int annotationsCodeIndex;
27

28
    /**
29
     * The access flags of the class, field, or method currently being parsed.
30
     */
31
    protected int access;
32

33
    /**
34
     * The generic type signature of the class/field/method, if it has one.
35
     */
36
    @Nullable
37
    protected String signature;
38

39
    protected AnnotatedReader(@NonNull byte[] code) {
40
        super(code);
1✔
41
    }
1✔
42

43
    protected AnnotatedReader(@NonNull AnnotatedReader another) {
44
        super(another);
1✔
45
    }
1✔
46

47
    protected final void readAttributes() {
48
        signature = null;
1✔
49
        annotationsCodeIndex = 0;
1✔
50

51
        for (int attributeCount = readUnsignedShort(); attributeCount > 0; attributeCount--) {
1✔
52
            String attributeName = readNonnullUTF8();
1✔
53
            int codeOffsetToNextAttribute = readInt();
1✔
54

55
            if ("Signature".equals(attributeName)) {
1✔
56
                signature = readNonnullUTF8();
1✔
57
                continue;
1✔
58
            }
59

60
            Boolean outcome = readAttribute(attributeName);
1✔
61

62
            if (outcome == Boolean.TRUE) {
1✔
63
                continue;
1✔
64
            }
65

66
            if (outcome == null) {
1✔
67
                // noinspection SwitchStatementWithoutDefaultBranch
68
                switch (attributeName) {
1!
69
                    case "RuntimeVisibleAnnotations":
70
                        annotationsCodeIndex = codeIndex;
1✔
71
                        break;
1✔
72
                    case "Deprecated":
73
                        access = Access.asDeprecated(access);
×
74
                        break;
×
75
                    case "Synthetic":
76
                        access = Access.asSynthetic(access);
×
77
                }
78
            }
79

80
            codeIndex += codeOffsetToNextAttribute;
1✔
81
        }
82
    }
1✔
83

84
    /**
85
     * Attempts to read the next attribute, provided it's one recognizable by the implementing subclass.
86
     *
87
     * @param attributeName
88
     *            the attribute name
89
     *
90
     * @return {@code true} if {@link #codeIndex} is already pointing to the next attribute in the classfile,
91
     *         {@code false} or {@code null} otherwise; in the case of {@code null}, the current attribute was not yet
92
     *         identified, but is one of the more general ones ("RuntimeVisibleAnnotations", "Deprecated", or
93
     *         "Synthetic")
94
     */
95
    @Nullable
96
    protected abstract Boolean readAttribute(@NonNull String attributeName);
97

98
    protected final void readAnnotations(@NonNull BaseWriter visitor) {
99
        if (annotationsCodeIndex > 0) {
1✔
100
            int previousCodeIndex = codeIndex;
1✔
101
            codeIndex = annotationsCodeIndex;
1✔
102

103
            for (int annotationCount = readUnsignedShort(); annotationCount > 0; annotationCount--) {
1✔
104
                String annotationTypeDesc = readNonnullUTF8();
1✔
105
                AnnotationVisitor av = visitor.visitAnnotation(annotationTypeDesc);
1✔
106
                readAnnotationValues(av);
1✔
107
            }
108

109
            codeIndex = previousCodeIndex;
1✔
110
        }
111
    }
1✔
112

113
    protected final void readAnnotationValues(@Nullable AnnotationVisitor av) {
114
        codeIndex = annotationReader.readNamedAnnotationValues(codeIndex, av);
1✔
115
    }
1✔
116
}
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

© 2026 Coveralls, Inc