• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • -noproxyinterfaces BOOLEAN

    Prev Next
    Builder
    Since 7.2.0
    Do not calculate Import-Package references for 'Proxy.newProxyInstance' usage found in method bodies during class processing.

    • Example: -noproxyinterfaces=true

    • Values: true,false

    • Pattern: true|false|TRUE|FALSE



    Normally, Bnd examines the method bodies of classes looking for the instruction sequence:

    Proxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)
    

    When Bnd detects a call to Proxy.newProxyInstance, it inspects the Class[] argument — for example, new Class[] { SomeInterface.class, ... } — and treats all listed interfaces as if they were implemented by the class. This means that any types referenced in the parameters or return types of those interfaces must also be imported.

    Example

    Consider the following code:

    return (ServletContext) Proxy.newProxyInstance(
        curClassLoader, 
        new Class[] { ServletContext.class }, 
        new AdaptorInvocationHandler()
    );
    

    Bnd will automatically add the package javax.servlet.descriptor to the Import-Package header, because the detected ServletContext interface declares the method JspConfigDescriptor getJspConfigDescriptor().

    Limitations

    Interface detection only occurs when the Class[] array is created inline (that is, using the anewarray bytecode pattern shown above). If the array is obtained from a field, local variable, or method parameter, Bnd cannot reliably determine its contents from the bytecode, and therefore no interfaces will be detected in those cases.

    Disabling Proxy Interface Detection

    The -noproxyinterfaces instruction can be used to tell Bnd not to search method bodies for calls to Proxy.newProxyInstance.

    For example:

    -noproxyinterfaces: true
    
Prev Next
Search
    • Home