Find Usages in Compiled Dependencies

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

This means that types of fields, types of method parameter and types of local variables are not indexed, so when searching for usages of type Foo, the IDE will discover:

  • a method call into Foo,
  • a read from or store to a field of Foo

But it does not find:

  • a field of type Foo
  • a method parameter of type Foo
  • a local variable, catch clause variable, resource variable of type Foo

Improving the search accurracy so would significantly enlarge indexes and slowed down dependency scanning, see performance analysis. According to established performance metrics, any slowdown of scanning is prohibited.

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.

Improving Search Accurracy

The accuracy of search can be improved in exchange of initial scan performance. Binary artifacts can be scanned more thoroughly but initial scan of JDK and maven dependencies will take significantly longer.

If you want to make Find (binary) usages more usable, please add the folliwng opiton into the etc/netbeans.conf:
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