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

raphw / byte-buddy / #769

01 May 2025 08:21PM UTC coverage: 85.141% (+0.002%) from 85.139%
#769

push

web-flow
Add Negation (#1804)

10 of 11 new or added lines in 1 file covered. (90.91%)

29383 of 34511 relevant lines covered (85.14%)

0.85 hits per line

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

90.91
/byte-buddy-dep/src/main/java/net/bytebuddy/implementation/bytecode/Negation.java
1
/*
2
 * Copyright 2014 - Present Rafael Winterhalter
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.bytebuddy.implementation.bytecode;
17

18
import net.bytebuddy.implementation.Implementation;
19
import org.objectweb.asm.MethodVisitor;
20
import org.objectweb.asm.Opcodes;
21

22
/**
23
 * A stack manipulation that negates a number on the operand stack.
24
 */
25
public enum Negation implements StackManipulation {
1✔
26

27
    /**
28
     * Negates an integer or an integer-compatible value.
29
     */
30
    INTEGER(Opcodes.INEG),
1✔
31

32
    /**
33
     * Negates a long.
34
     */
35
    LONG(Opcodes.LNEG),
1✔
36

37
    /**
38
     * Negates a float.
39
     */
40
    FLOAT(Opcodes.FNEG),
1✔
41

42
    /**
43
     * Negates a double.
44
     */
45
    DOUBLE(Opcodes.DNEG);
1✔
46

47
    /**
48
     * The opcode to apply.
49
     */
50
    private final int opcode;
51

52
    /**
53
     * Creates a new negation.
54
     *
55
     * @param opcode The opcode to apply.
56
     */
57
    Negation(int opcode) {
1✔
58
        this.opcode = opcode;
1✔
59
    }
1✔
60

61
    /**
62
     * {@inheritDoc}
63
     */
64
    public boolean isValid() {
NEW
65
        return true;
×
66
    }
67

68
    /**
69
     * {@inheritDoc}
70
     */
71
    public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) {
72
        methodVisitor.visitInsn(opcode);
1✔
73
        return StackManipulation.Size.ZERO;
1✔
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc