All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.samples.java.ex.UNNC_Sample Maven / Gradle / Ivy

Go to download

An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.

The newest version!
package ex;

import java.util.ArrayList;
import java.util.List;

public class UNNC_Sample {

    public void testPosNEW() {
        UNNC_Sample sample = new UNNC_Sample();

        if (sample != null) {
            System.out.println("OK");
        }
    }

    public void testNegNEW() {
        UNNC_Sample sample = new UNNC_Sample();

        if (sample == null) {
            return;
        }

        System.out.println("OK");
    }

    public void testPosANEWARAY() {
        String[] s = new String[10];
        if (s != null) {
            System.out.println("OK");
        }
    }

    public void testNegANEWARRAY() {
        String[] s = new String[10];
        if (s == null) {
            return;
        }

        System.out.println("OK");
    }

    public void testPosMULTIANEWARRAY() {
        String[][] s = new String[10][5];
        if (s != null) {
            System.out.println("OK");
        }
    }

    public void testNegMULTIANEWARRAY() {
        String[][] s = new String[10][5];
        if (s == null) {
            return;
        }

        System.out.println("OK");
    }

    public void testFPFinally() throws Exception {
        StringBuilder sb = null;
        try {
            sb = new StringBuilder();
            sb.append("False Positive");
        } finally {
            if (sb != null) {
                sb.setLength(0);
            }
        }
    }

    public void testTrinary(Boolean b) {
        List l = (b == null) ? null : new ArrayList();

        if (l != null) {
            l.add("foo");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy