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 47169 - DOMFactoryImpl causes tests with core.jar in classpath using JAXP to break under JDK 1.5
Summary: DOMFactoryImpl causes tests with core.jar in classpath using JAXP to break un...
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: PC Linux
: P1 blocker (vote)
Assignee: Petr Nejedly
URL:
Keywords: REGRESSION, T9Y
Depends on:
Blocks: 41925
  Show dependency tree
 
Reported: 2004-08-12 18:24 UTC by Jesse Glick
Modified: 2008-12-22 22:38 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Demonstration of failure under JDK 1.5 (8.89 KB, text/plain)
2004-08-12 18:25 UTC, Jesse Glick
Details
Same test passing on JDK 1.4 (783 bytes, text/plain)
2004-08-12 18:26 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-08-12 18:24:51 UTC
After your patch for issue #41925,
apisupport/project/test/unit/src/org/netbeans/modules/apisupport/project/ClassPathProviderImplTest.java
fails with an error when run under JDK 1.5 (b62).
I am attaching output with jaxp.debug set to true,
by creating
apisupport/project/nbproject/private/private.properties
with

test-unit-sys-prop.jaxp.debug=true

The line

j.x.p.DBF=null

indicates where DOMFactoryImpl is being
initialized and is about to call
DocumentBuilderFactory.newInstance().

Note the (repeated) lines

JAXP: find factoryId
=javax.xml.parsers.DocumentBuilderFactory
JAXP: found jar
resource=META-INF/services/javax.xml.parsers.DocumentBuilderFactory
using ClassLoader: null
JAXP: found in resource,
value=org.netbeans.core.xml.DOMFactoryImpl

What is happening? My guess:
FactoryFinder.findJarServiceProvider is finding a
context class loader which is non-null,
specifically the ext class loader. The first call
to ss.getResourceAsStream fails - there is no
provider in rt.jar (or extensions). Then cl is set
to null (FactoryFinder is in rt.jar) and ss.gRAS
is called again, this time with a null loader. Now
SecuritySupport.gRAS has this code:

if (cl == null) {
    ris = ClassLoader.getSystemResourceAsStream(name);
} else {
    ris = cl.getResourceAsStream(name);
}

Looks reasonable at first. Unfortunately
ClassLoader.gSRAS is defined as using
CL.getSystemClassLoader, which is not what we want
here - really what is wanted is
CL.getBootstrapResource, but that is private. The
problem is that CL.gSCL gives the app class
loader, which has core.jar in it (when running in
a unit test), and core.jar does have M-I/s entries
for JAXP. That means that newInstance is called
with a valid class name - o.n.c.DOMFactoryImpl -
but with a null class loader, which of course
fails since the class is not in the bootstrap loader.

IMHO this is a JDK bug and a regression from JDK
1.4 and must be filed with a minimal test case
ASAP. Probably SS.gRAS should simply return null
if cl == null, since the packagers of the JDK can
know that there are no JAXP providers in rt.jar.

In the meantime I recommend #41925 be rolled back
or implemented differently (no suggestions at the
moment, other than moving the code into an obscure
module in ide/* where it will never be used by
unit tests).

Generally, fooling around with JAXP providers is
always asking for trouble; the code is far too
complicated and deeply buggy. I was quite relieved
when we deleted the previous core-supplied JAXP
providers; a bunch of unsolvable problems
disappeared at that time (affecting unit tests,
Ant integration, etc.).
Comment 1 Jesse Glick 2004-08-12 18:25:50 UTC
Created attachment 16787 [details]
Demonstration of failure under JDK 1.5
Comment 2 Jesse Glick 2004-08-12 18:26:30 UTC
Created attachment 16788 [details]
Same test passing on JDK 1.4
Comment 3 _ ttran 2004-08-13 13:09:33 UTC
Petr N: working on it?

Is this beta1 stopper?
Comment 4 Jan Chalupa 2004-08-13 13:19:19 UTC
The user impact is unclear to me. Jesse, do you think this is a "must
fix" for Beta 1? Has a bug been filed against JDK?
Comment 5 Petr Nejedly 2004-08-13 16:13:49 UTC
> Petr N: working on it?

Yes, for now I have at least removed the registrations.

> Is this beta1 stopper?
Shouldn't be. It manifests itself only in tests, more specicifally
when there is a factory registered on app classpath (note: neither the
factory nor the core itself is on app classpath in NB, they are both
deeper)

Note: It was both compilable and working on my copy of 1.5 JDK. Oh
well, it was a bit outdated. I think we'll need to add a requirement
to download latest subsubversion of JDK before commit-validating...

I haven't filed a JDK issue yet (hard to run remote-X bugtraq from WFH).
Comment 6 Jesse Glick 2004-08-13 18:15:57 UTC
It is manifested in tests - making it impossible to run many unit
tests under JDK 1.5, which is a serious problem of course. It would
also be manifested in any app based on a subset of the NB platform,
i.e. using core.jar as a simple library. It is not (AFAIK) manifested
in the IDE nor in the proper platform, i.e. using the regular module
system and file layout and launcher. I don't see it as a beta stopper.

BTW possible workaround: catch FactoryConfigurationError (or whatever
it is) and try to fall back to known factory class names: Crimson,
Xerces (original packaging & 1.5 repackaging).
Comment 7 Tomas Danek 2005-07-27 11:08:40 UTC
no further comments to this - closing. feel free to reopen