This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 141698 - Allow private classes as .instance files
Summary: Allow private classes as .instance files
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-25 16:18 UTC by Andrei Badea
Modified: 2010-11-26 06:14 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Suggested change (761 bytes, text/plain)
2008-07-25 16:20 UTC, Andrei Badea
Details
Changes in fs, loaders and core.startup (4.78 KB, patch)
2008-08-15 11:13 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2008-07-25 16:18:50 UTC
An instance of the following class

    private class example.Foo {
    
        private Foo create() { return new Foo(); }
    
        private Foo() {}
    }

currently must be registered in a layer file as

    <file name="...">
        <attr name="instanceCreate" methodvalue="example.Foo.create"/>
    </file>

and not simply as

    <file name="example-Foo.instance"/>

In the former case, setAccessible(true) is called on the instanceCreate method, but in the latter case
Class.newInstance() is used, which throws an exception for the above class.

Please review the attached patch, which attempts to make it possible to call a private constructor to create the instance.
Comment 1 Andrei Badea 2008-07-25 16:20:29 UTC
Created attachment 65651 [details]
Suggested change
Comment 2 Andrei Badea 2008-07-25 16:21:56 UTC
Not for 6.5. Please review and reassign to me if you agree with the change.
Comment 3 Jaroslav Tulach 2008-08-15 11:11:47 UTC
The change spans more modules, but mostly it needs to be done in filesystems. Passing to Jirka. I'll attach improved 
patch, but it needs API review, bit of documentation and proper versioning, imho.
Comment 4 Jaroslav Tulach 2008-08-15 11:13:56 UTC
Created attachment 67514 [details]
Changes in fs, loaders and core.startup
Comment 5 Jiri Skrivanek 2008-08-21 14:36:46 UTC
I agree with changes. Please, drive API review yourself.
Comment 6 Jesse Glick 2009-03-10 22:15:22 UTC
Do we really want this? I would say no - what you register needs to be marked public (though it could be in a private
package). Anyway new API usages should be driven by annotations.
Comment 7 Jaroslav Tulach 2010-11-24 21:25:02 UTC
I think we want this for consistency. Factory methods can be private, let's allow private constructors as well.
Comment 8 Jaroslav Tulach 2010-11-25 07:35:25 UTC
core-main#b300d4386b1e
Comment 9 Quality Engineering 2010-11-26 06:14:26 UTC
Integrated into 'main-golden', will be available in build *201011260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/b300d4386b1e
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #141698: Allow private classes as .instance objects