[
https://issues.apache.org/jira/browse/JENA-878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14319312#comment-14319312
]
ASF GitHub Bot commented on JENA-878:
-------------------------------------
GitHub user stain opened a pull request:
https://github.com/apache/jena/pull/31
JENA-878 Avoid exposing xerces.impl.dv
Not quite a fix to
[JENA-878](https://issues.apache.org/jira/browse/JENA-878) - but avoid the
dangerous OSGi implications of requiring an export of
`org.apache.xerces.impl.dv`.
This patch makes any method signature that involves
org.apache.xerces.impl.dv package-private, e.g. those sending around
`ValidationInfo`.
This meant moving `XSDGenericType` to become an inner class of XSDDatatype.
It could in theory be a separate class in the same package - but it shouldn't
"really" be exposed or promoted - so I thought it was better to hide it in
plain sight inside XSDDatatype which is the only class using it directly.
I suggested now for `XSDDatatype.XSDGenericType` remains public as the
other `impl.XSD*` classes are public - I guess they could be used mainly for
`instanceof` checks? If not the class itself can also be made package-private
or even private.
This removes these particular warnings from jena-osgi about
`org.apache.xerces.impl.dv`:
```
[WARNING] Bundle org.apache.jena:jena-osgi:bundle:2.13.0-SNAPSHOT :
Export com.hp.hpl.jena.datatypes.xsd, has 1, private references
[org.apache.xerces.impl.dv],
[WARNING] Bundle org.apache.jena:jena-osgi:bundle:2.13.0-SNAPSHOT :
Export com.hp.hpl.jena.datatypes.xsd.impl, has 1, private references
[org.apache.xerces.impl.dv],
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/stain/jena JENA-878-avoid-exposing-impl
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jena/pull/31.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #31
----
commit 8d6a2cdfb348e3deab744b016f03e3e42aa67122
Author: Stian Soiland-Reyes <[email protected]>
Date: 2015-02-12T22:44:09Z
JENA-878: Explicit imports of org.apache.xerces.impl.dv
.. by doing Organize Imports in Eclipse.
not that it solves JENA-878, but at least we would know
more explicitly which org.apache.xerces.impl classes
we depend on.
commit 830b9c30223b2d2f4a4a7732821e1b41fee2467f
Author: Stian Soiland-Reyes <[email protected]>
Date: 2015-02-13T00:00:34Z
JENA-878 Not exposing xerces.dv.impl in method signatures
commit 077c6ef71fe469884b830366fac60a60caf4ca9b
Author: Stian Soiland-Reyes <[email protected]>
Date: 2015-02-13T00:07:17Z
JENA-878: XSDGenericType now inner class of XSDDatatype
.. the only one who one would think
needs to construct using xerces.impl.dv.XSSimpleType
(via loadUserDefined)
XSDGenericType now has a package-protected constructor
as well to avoid leaking its XSSimpleDV
outside this package.
It was in com.hp.hpl.jena.datatypes.xsd.impl. before,
so removing this is allowed given a new
minor version number.
comments used to say:
This class is probably now redundant in that XSDDatatype can
support run time conversion of union results. Left in for now
during restructuring and in case any existing user code expects
this type - very unlikely.
commit 1c7455bbf1e162eebfb87f67e7df3ec82331916d
Author: Stian Soiland-Reyes <[email protected]>
Date: 2015-02-13T00:14:47Z
JENA-878: Updated javadocs on XSDGenericType
----
> Avoid dependencies on xerces.impl
> ---------------------------------
>
> Key: JENA-878
> URL: https://issues.apache.org/jira/browse/JENA-878
> Project: Apache Jena
> Issue Type: Task
> Components: Jena
> Affects Versions: Jena 2.13.0
> Reporter: Stian Soiland-Reyes
> Priority: Minor
>
> Building jena-osgi complains about xerces.impl dependencies:
> > [WARNING] Bundle org.apache.jena:jena-osgi:bundle:2.12.2-SNAPSHOT : Unused
> > Private-Package instructions, no such package(s) on the class path: [!*]
> > [WARNING] Bundle org.apache.jena:jena-osgi:bundle:2.12.2-SNAPSHOT : Export
> > com.hp.hpl.jena.datatypes.xsd, has 1, private references
> > [org.apache.xerces.impl.dv],
> {code}
> stain@biggie-utopic:~/src/jena/jena-core/src/main/java/com/hp/hpl/jena/datatypes$
> grep -r xerces.*impl .
> ./xsd/XSDDatatype.java:import org.apache.xerces.impl.dv.* ;
> ./xsd/XSDDatatype.java:import org.apache.xerces.impl.dv.util.Base64 ;
> ./xsd/XSDDatatype.java:import org.apache.xerces.impl.dv.util.HexBin ;
> ./xsd/XSDDatatype.java:import org.apache.xerces.impl.dv.xs.DecimalDV ;
> ./xsd/XSDDatatype.java:import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl ;
> ./xsd/XSDDatatype.java:import
> org.apache.xerces.impl.validation.ValidationState ;
> ./xsd/XSDhexBinary.java:import org.apache.xerces.impl.dv.util.HexBin ;
> ./xsd/XSDbase64Binary.java:import org.apache.xerces.impl.dv.util.Base64 ;
> ./xsd/impl/XSDGenericType.java:import org.apache.xerces.impl.dv.XSSimpleType;
> {code}
> It is not good style to depend on *.impl of a package - it is liable to fall
> over at some point. jena-osgi complains, but works in this particular case,
> because xercesImpl is shadowed in.
> Some/all of these (base64) are available through more official packages -
> org.apache.commons.codec.binary.Base64 comes to mind.
> https://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Base64.html
> https://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Hex.html
> So this task suggests to replace these dependencies with commons-codec
> versions. Remember to add commons-codec to jena-osgi as well!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)