I got a little closer to the problem now.
So, take this line and debug it a) in plain Java 11, and b) in this
NetBeans platform (any version but running on JDK 11):

java.lang.Package p = Main.class.getPackage();

Class java.lang.Package in Java 11 differs in many aspects from Java 8. In
Java 11, it has a private field called "packageInfo" of type "Class<?>",
which in cases

a) (the working case) is a reference to the actual package-info class
object, i.e. MyPackage.package-info

b) always references "java.lang.Package$1PackageInfoProxy", i.e. the
java.lang.Package class object (and therefore NOT the class object
resulting from the compilation of e.g. MyPackage.package-info.java as it
would be supposed).

This is a bug. It's most likely a NetBeans classloader issue.

Boris

On Sat, 12 Oct 2019 at 09:44, Boris Heithecker <boris.heithec...@gmx.net>
wrote:

> It's definitely not a JDK problem. The code works fine in a non-platform
> application with jdk11.0.4. It's a problem of the combination JDK 11 plus
> NetBeans Platform. It fails even if I switch to JDK 11 and NetBeans 8.2.
> Boris
>
> Geertjan Wielenga <geert...@apache.org> schrieb am Sa., 12. Okt. 2019,
> 09:14:
>
>> So first start by using the same JDK for both to see whether it is a JDK
>> problem (probably since JDK 11 is very different to JDK 8) or not.
>>
>> Gj
>>
>> On Sat, 12 Oct 2019 at 08:50, Boris Heithecker <boris.heithec...@gmx.net>
>> wrote:
>>
>>> Hi all,
>>> it seems that a NetBeans 11.1 platform app running on Java 11 (oracle
>>> jdk11.0.4) doesn't read annotations at package level properly. If I'm not
>>> mistaken for whatever reason this is a really nasty bug.
>>>
>>> Please have a look at this to reproduce:
>>>
>>> https://github.com/borisheithecker/packagelevelannotationtest
>>>
>>> If I run this small platform application with platform 11.1 and Java 11
>>> selected, it fails (i.e. the package annotation is not found at runtime).
>>> If I run it with NetBeans 8.2 and Java 8_162 the annotation is found as
>>> expected.
>>>
>>> I started porting a platform application yesterday which has been run on
>>> 8.2 so far and which makes heavy use of JAXB and Web Services. I spend
>>> the
>>> whole day digging various sources on why the application fails to run on
>>> Java 11 (with Metro JAX WS RI added as external library) until I found
>>> out
>>> what seems to be the obvious reason now: it fails because JAXB can't
>>> read @XmlSchema-annotations in package-info. Am I doing something wrong?
>>>
>>> Boris
>>>
>>

-- 
Boris Heithecker


Dr. Boris Heithecker
Lüneburger Str. 30
28870 Ottersberg
Festnetz: +49 4205 315834
Mobil: +49 170 6137015

Reply via email to