• 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

82.54
/main/src/main/java/mockit/asm/BaseWriter.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 java.util.List;
12

13
import mockit.asm.annotations.AnnotationVisitor;
14
import mockit.asm.constantPool.ConstantPoolGeneration;
15
import mockit.asm.jvmConstants.Access;
16
import mockit.asm.util.ByteVector;
17

18
import org.checkerframework.checker.index.qual.NonNegative;
19

20
public class BaseWriter {
21
    /**
22
     * The dynamically generated constant pool of the class being built/modified.
23
     */
24
    protected ConstantPoolGeneration cp;
25

26
    /**
27
     * The access flags of this class, field, or method.
28
     */
29
    protected int classOrMemberAccess;
30

31
    @NonNegative
32
    private int deprecatedAttributeIndex;
33
    @NonNegative
34
    private int syntheticAttributeIndex;
35

36
    /**
37
     * The runtime visible annotations of this class/field/method.
38
     */
39
    @Nullable
40
    protected AnnotationVisitor annotations;
41

42
    protected BaseWriter() {
1✔
43
    }
1✔
44

45
    protected BaseWriter(@NonNull ConstantPoolGeneration cp, int classOrMemberAccess) {
1✔
46
        this.cp = cp;
1✔
47
        this.classOrMemberAccess = classOrMemberAccess;
1✔
48
    }
1✔
49

50
    /**
51
     * Returns the {@link #cp constant pool generation helper object} used by this writer.
52
     *
53
     * @return the constant pool generation
54
     */
55
    @NonNull
56
    public final ConstantPoolGeneration getConstantPoolGeneration() {
57
        return cp;
1✔
58
    }
59

60
    /**
61
     * Visits an annotation of the class/field/method being visited.
62
     *
63
     * @param desc
64
     *            the descriptor of the annotation type
65
     *
66
     * @return a visitor to visit the annotation values, or <code>null</code> if this visitor is not interested in
67
     *         visiting the annotation
68
     */
69
    @Nullable
70
    public AnnotationVisitor visitAnnotation(@NonNull String desc) {
71
        return addAnnotation(desc);
1✔
72
    }
73

74
    @NonNull
75
    private AnnotationVisitor addAnnotation(@NonNull String desc) {
76
        AnnotationVisitor aw = new AnnotationVisitor(cp, desc);
1✔
77
        aw.setNext(annotations);
1✔
78
        annotations = aw;
1✔
79
        return aw;
1✔
80
    }
81

82
    /**
83
     * Visits the end of the class/field/method being visited. This method, which is the last one to be called, is used
84
     * to inform the visitor that all the annotations and attributes of the class/field/method have been visited.
85
     */
86
    public void visitEnd() {
87
    }
1✔
88

89
    protected final void createMarkerAttributes(int classVersion) {
90
        if (Access.isDeprecated(classOrMemberAccess)) {
1!
91
            deprecatedAttributeIndex = cp.newUTF8("Deprecated");
×
92
        }
93

94
        if (Access.isSynthetic(classOrMemberAccess, classVersion)) {
1!
95
            syntheticAttributeIndex = cp.newUTF8("Synthetic");
×
96
        }
97
    }
1✔
98

99
    @NonNegative
100
    protected final int getAnnotationsSize() {
101
        if (annotations != null) {
1✔
102
            getConstantPoolItemForRuntimeVisibleAnnotationsAttribute();
1✔
103
            return 8 + annotations.getSize();
1✔
104
        }
105

106
        return 0;
1✔
107
    }
108

109
    @NonNegative
110
    private int getConstantPoolItemForRuntimeVisibleAnnotationsAttribute() {
111
        return cp.newUTF8("RuntimeVisibleAnnotations");
1✔
112
    }
113

114
    @NonNegative
115
    protected final int getMarkerAttributeCount() {
116
        return (deprecatedAttributeIndex == 0 ? 0 : 1) + (syntheticAttributeIndex == 0 ? 0 : 1);
1!
117
    }
118

119
    @NonNegative
120
    protected final int getMarkerAttributesSize() {
121
        int attributeCount = getMarkerAttributeCount();
1✔
122
        return 6 * attributeCount;
1✔
123
    }
124

125
    protected final void putAccess(@NonNull ByteVector out, int baseMask) {
126
        int accessFlag = Access.computeFlag(classOrMemberAccess, baseMask);
1✔
127
        out.putShort(accessFlag);
1✔
128
    }
1✔
129

130
    protected final void putMarkerAttributes(@NonNull ByteVector out) {
131
        if (deprecatedAttributeIndex > 0) {
1!
132
            out.putShort(deprecatedAttributeIndex).putInt(0);
×
133
        }
134

135
        if (syntheticAttributeIndex > 0) {
1!
136
            out.putShort(syntheticAttributeIndex).putInt(0);
×
137
        }
138
    }
1✔
139

140
    protected final void putAnnotations(@NonNull ByteVector out) {
141
        if (annotations != null) {
1✔
142
            int item = getConstantPoolItemForRuntimeVisibleAnnotationsAttribute();
1✔
143
            out.putShort(item);
1✔
144
            annotations.put(out);
1✔
145
        }
146
    }
1✔
147

148
    protected void put(@NonNull ByteVector out) {
149
    }
×
150

151
    protected static void put(@NonNull ByteVector out, @NonNull List<? extends BaseWriter> writers) {
152
        out.putShort(writers.size());
1✔
153

154
        for (BaseWriter writer : writers) {
1✔
155
            writer.put(out);
1✔
156
        }
1✔
157
    }
1✔
158
}
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