Skip to content

Provide APIs for construction with potentially inaccessible constructors #6

@giltene

Description

@giltene

Pull request #4 raises a need to make some constructors (e.g. default constructor in the specific pull request case) useable when constructing objects using IntrinsicObjectModel. Similar needs exist in StructuredArray, and in some case they are supported by making the constructor accessible via reflection.

I am trying to avoid making constructors accessible this way for both default or non-default constructors, and will probably look to avoid doing the same in some of the StructuredArray cases that currently do (taking away the current accessible-forcing behavior). Making e.g. private or protected constructors accessible can lead to surprising and potentially insecure construction behavior.

Obviously, we have a problem here, in that a class that has access to a certain constructor that is not accessible from IntrinsicObjectModel or IntrinsicStraturedArray may want to declare intrinsic fields, structured arrays or inner classes with such fields or arrays using that accessible-only-to-it constructor. This will not be possible with the current API.

My hope is to address such situations in Java 7 and beyond with method handles. Unlike reflective calls to constructors, which have their accessibility checked at invocation time based on the calling class, Method handle based calls to constructors have the accessibility checked at lookup time. A class with access to a certain constructor can therefore provide a method handle to that constructor in a way that can be executed by IntrinsicObjectModel or IntrinsicStraturedArray.

Will update this issue when we make more progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions