Peter Kriens wrote:
RSH> My desire is not to cause people using Felix any undue pain. I certainly
RSH> want Felix to work properly out of the box, but how will we ever learn
RSH> about these issues and improve the situation if we never try?
Maybe you can log any delegation to the bootclasspath as a warning?
Yes, that is a possibility. However, the Swing LAF example that was
resolved without needing to import "com.sun.*" or "sun.*" is really
telling. By exposing these hidden dependencies in a more strict way,
then we can actually learn something from them. Making them too easy to
ignore just creates more of the same issues.
Still, I agree that we should try to make being more strict as painless
as possible. Another possible approach is for us to try to improve
Felix' error diagnostics when a class loading error occurs. For example,
we could:
* Check to see if there are exporters of the package, but no import
and suggest adding it to the Import-Package declaration.
* Check to see if the class is available from the system class
loader and suggest adding the package to the system bundle's packages.
* Check to see if the class is being loaded using
ClassLoader.loadClassInternal() by examing the stack trace and
suggest to add the package to the boot delegation property.
Perhaps there are other possible diagnostics that could help developers
when they encounter a class loading error.
-> richard
Kind regards,
Peter Kriens
RSH> John E. Conlon wrote:
the problem lay in another part of the class where I build the menu
items to allow the user to change the configuration of the LAF. For that
I needed to determine if my string classnames were accessible.
Here is the problematic way:
static boolean isAvailableLookAndFeel(String laf) {
try {
Class lnfClass = Class.forName(laf);
LookAndFeel newLAF = (LookAndFeel) (lnfClass.newInstance());
return newLAF.isSupportedLookAndFeel();
} catch (Exception e) {
return false;
}
}
The right way to do this is to use the
javax.swing.UIManager.getInstalledLookAndFeels() method
which returns an array of LookAndFeelInfo objects. An LookAndFeelInfo
object can then be used for building the menu items.
After refactoring the class I was able to remove the
com.sun.java.swing.plaf.gtk;
com.sun.java.swing.plaf.motif;
package imports from the bundle and the from the
org.osgi.framework.system.packages property.
The bundle then loaded without error.
RSH> Interesting. Thanks for looking into this in detail.
RSH> However, did you check out the latest version of Felix since I did add
RSH> "com.sun.*" and "sun.*" to the boot delegation property.
RSH> If this is accurate, then it basically demonstrates my thinking exactly.
RSH> We either can by default try to be a little more strict and look into
RSH> problems and try to figure them out in a proper modular fashion or do we
RSH> just forget about it and allow more and more and more legacy to be built
RSH> with the same modularity problems. I am in the camp of the former.
RSH> My desire is not to cause people using Felix any undue pain. I certainly
RSH> want Felix to work properly out of the box, but how will we ever learn
RSH> about these issues and improve the situation if we never try?
->> richard