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 190165 - Inadequate documentation for Java Platform API
Summary: Inadequate documentation for Java Platform API
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Platform (show other bugs)
Version: 6.x
Hardware: Other Linux
: P2 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-05 19:26 UTC by Jaroslav Tulach
Modified: 2010-10-20 13:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample lejos-rcx project of mine (12.61 KB, application/octet-stream)
2010-10-20 07:18 UTC, Jaroslav Tulach
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2010-09-05 19:26:21 UTC
I am trying to provide my own implementation of Java Platform. I am trying to avoid looking into source code, I am only relying on Javadoc. I believe it is not possible to succeed in this task with such restrictions. The documentation does not seem to be adequate.

1. I have my implementation of PlatformInstall. Where shall I register it and how? I tried @ServiceProvider(...) but no luck. This shall be part of javadoc for http://bits.netbeans.org/6.9.1/javadoc/org-netbeans-modules-java-platform/org/netbeans/spi/java/platform/PlatformInstall.html
and/or http://bits.netbeans.org/6.9.1/javadoc/org-netbeans-modules-java-platform/org/netbeans/spi/java/platform/GeneralPlatformInstall.html

2. I guess I know what to do inside accept method (once it is called). I have no idea what createIterator method shall do. It's javadoc confirms I am not the only one:
http://bits.netbeans.org/6.9.1/javadoc/org-netbeans-modules-java-platform/org/netbeans/spi/java/platform/PlatformInstall.html#createIterator(org.openide.filesystems.FileObject)
Where the instance shall be created?

A bit of demo code would be helpful.
Comment 1 Jaroslav Tulach 2010-09-06 23:09:48 UTC
OK, I started to read the java.platform code. This is how I can install my platform install:

@ServiceProvider(
    service=GeneralPlatformInstall.class,
    path="org-netbeans-api-java/platform/installers"
)
public final class LejosPlatformInstall extends PlatformInstall {
}
Comment 2 Tomas Zezula 2010-09-30 14:25:09 UTC
Fixed jet-main 310a178b39ae
Comment 3 Quality Engineering 2010-10-01 03:10:14 UTC
Integrated into 'main-golden', will be available in build *201010010000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/310a178b39ae
User: Tomas Zezula <tzezula@netbeans.org>
Log: #190165:Inadequate documentation for Java Platform API
Comment 4 Jaroslav Tulach 2010-10-04 06:27:40 UTC
Slight adjustments (hopefully correct) in 
http://hg.netbeans.org/core-main/rev/f6c8d20ade0a
Comment 5 minashokry 2010-10-20 01:43:55 UTC
Documentation is still incomplete and there is something incorrect.

First,
The "public java.util.Set instantiate() throws IOException" method has to return a Set of JavaPlatform not InstanceObject, the code in the example documentation causes a ClassCastException.

the line 
-----
return Collections.singleton(InstanceDataObject.create(
DataFolder.findFolder(FileUtil.getConfigFile("Services/Platforms/org-netbeans-api-java-Platform")),
theName,
p,
null,
true));
------
has to be changed to 
-----
return Collections.singleton(InstanceDataObject.create(
DataFolder.findFolder(FileUtil.getConfigFile("Services/Platforms/org-netbeans-api-java-Platform")),
theName,
p,
null,
true).instanceCreate());
-----

Then, even with this addition, It still doesn't work. I diagnosed the problem like this
-----------------
In org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java method refreshPlatforms() line 638
JavaPlatform platform = node.getLookup().lookup(JavaPlatform.class);
after this line the "platform" reference points to null which means there is something other incorrect in the method instantiate. Please update the documentation to tell the right way. I can't fix it yet.
Comment 6 Jaroslav Tulach 2010-10-20 07:18:44 UTC
Created attachment 102507 [details]
Sample lejos-rcx project of mine

Here is the sample project that I have. Use following commands to get my sources. If you want to build up on them, go on.

~$ mkdir lejos
~$ cd lejos/
~/lejos$ hg init
~/lejos$ hg unbundle ~/lejos-rcx.hg 
adding changesets
adding manifests
adding file changes
added 4 changesets with 19 changes to 16 files
(run 'hg update' to get a working copy)
~/lejos$ hg update
Comment 7 Tomas Zezula 2010-10-20 13:29:44 UTC
Fixe the javadoc.
Fixed jet-main 6c35f5f5d12e.

Regarding the PlatformsCustomizer:
The null is OK and according to doc.
The javadoc says:
The platform definition file has to represent the JavaPlatform instance.
This can be done in many ways. For example using the ConvertAsJavaBean annotation
If you look at the customizer sources:

http://hg.netbeans.org/jet-main/file/2ea59ca380d1/java.platform/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java

The customizer lookups Platform in the Node, if it's not there it lookups InstanceCookie and uses it to create the platform.