Find Usages in Compiled Dependencies

Revision as of 13:20, 30 August 2015 by Ralphbenjamin (Talk | contribs)

To find where a class, interface, method, or field is used in your project, you use the Find Usages command. From NetBeans 8.1 you can also find where they are used in the dependencies of your project. To get the results from your project's dependencies, NetBeans indexes the binary version of these dependencies. Searching for usages in compiled dependencies has certain limitations.


Find Usages limitations

Missing type references in the byte code

Missing Annotations with RetentionPolicy.SOURCE

Annotations with RetentionPolicy.SOURCE are to be discarded by the compiler.

example from API Design

public @interface Words {
public class WordsFactory {
    public static String[] myWords() {
        return new String[] {

The @Words annotation has RetentionPolicy.SOURCE. This means that it shall not propagate to resulting bytecode and will not be found in dependencies.

Unused imports

Unused imports will be discarded by the compiler.


public class Foo {

Field access on constants.

According to JLS the constant is defined as static final primitive type or string which value is constant in compile time. For example: public static final String PROP_ENTRIES = "entries"; In the JDK 9 there should be an unused CONSTANT_Fieldref in constant pool emitted by compiler which will fix the problem.

References from if (compile time false) blocks.

private static final boolean DEBUG = false;
if (DEBUG) {


Missing references on types which are just referred in the method bodies (no method call or field access is done on them) unless you compile with -g:vars. These references are not present due to missing Local Variable Table.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo