eclipse-pde / eclipse.pde

Eclipse Public License 2.0
28 stars 73 forks source link

SWT has ~130 API errors showing "no longer an API" markers for API code #1187

Closed iloveeclipse closed 7 months ago

iloveeclipse commented 7 months ago

After fixing https://github.com/eclipse-pde/eclipse.pde/issues/1073 I hoped to see no more API errors on SWT, but some dark force will not give up on that and immediately with the begin of 4.32 development I see again ~130 API errors on SWT. As usually, I can build as many times as I can, errors do not disappear...

image

The nightmare is back, org.eclipse.swt.gtk.linux.x86_64 project has lot of API errors... :-( I'm running I20240306-1800 build, baseline is set to 4.31 RC2.

It looks like all the classes/fields carrying @noextend or @noreference are not considered API anymore.

I don't see any changes in 4.32 that would cause that, the latest from 4.31 that could be related would be https://github.com/eclipse-pde/eclipse.pde/pull/1094, but I haven't seen API errors before, running most of the 4.31 builds.

Anyone else seeing this or has an idea what could be wrong?

iloveeclipse commented 7 months ago

I can reproduce on Windows too, and also in debugger. Touching Display class in editor (triggers API builder) and looking at Display class visited in ClassFileComparator.getDelta() I see that IApiDescription.resolveAnnotations(IElementDescriptor) returns API / NO_EXTEND annotation for the workspace class and API / NO_RESTRICTIONS for the baseline class. That is definitely wrong end explains the weird API analysis.

The descriptions seem to be coming from ApiDescription.findNode(IElementDescriptor, boolean) but that one can't find a description for the Display class type so it returns description for the package and there are no restrictions.

I see that .api_description file is almost empty in org.eclipse.swt.win32.win32.x86_64_3.125.0.v20240227-1638.jar from 4.31 RC2:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component name="org.eclipse.swt.win32.win32.x86_64_3.125.0.v20240227-1638" version="1.2">
    <plugin id="org.eclipse.swt.win32.win32.x86_64_3.125.0.v20240227-1638"/>
</component>

whereas it is full of data in org.eclipse.swt.win32.win32.x86_64_3.124.200.v20231113-1355.jar from 4.30RC2:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component name="org.eclipse.swt.win32.win32.x86_64_3.124.200.v20231113-1355" version="1.2">
    <plugin id="org.eclipse.swt.win32.win32.x86_64_3.124.200.v20231113-1355"/>
    <package name="org.eclipse.swt.accessibility" visibility="1">
        <type name="Accessible" restrictions="0">
            <method name="internal_WM_GETOBJECT" restrictions="8" signature="(JJ)J"/>
            <method name="internal_dispose_Accessible" restrictions="8" signature="()V"/>
            <method name="internal_new_Accessible" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Control;)Lorg/eclipse/swt/accessibility/Accessible;"/>
        </type>
    </package>
    <package name="org.eclipse.swt.browser" visibility="1">
        <type name="Browser" restrictions="2"/>
    </package>
    <package name="org.eclipse.swt.custom" visibility="1">
        <type name="CBanner" restrictions="2"/>
        <type name="CTabFolder" restrictions="2"/>
        <type name="CTabItem" restrictions="2"/>
        <type name="StyledText" restrictions="2"/>
        <type name="ViewForm" restrictions="2"/>
    </package>
    <package name="org.eclipse.swt.dnd" visibility="1">
        <type name="Clipboard" restrictions="2"/>
        <type name="DragSource" restrictions="2"/>
        <type name="DropTarget" restrictions="2"/>
        <type name="TransferData" restrictions="0">
            <field name="formatetc" restrictions="8"/>
            <field name="pIDataObject" restrictions="8"/>
            <field name="result" restrictions="8"/>
            <field name="stgmedium" restrictions="8"/>
            <field name="type" restrictions="8"/>
        </type>
    </package>
    <package name="org.eclipse.swt.graphics" visibility="1">
        <type name="Color" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;I)Lorg/eclipse/swt/graphics/Color;"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;II)Lorg/eclipse/swt/graphics/Color;"/>
        </type>
        <type name="Cursor" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;I)Lorg/eclipse/swt/graphics/Cursor;"/>
        </type>
        <type name="Device" restrictions="0">
            <method name="getDeviceZoom" restrictions="24" signature="()I"/>
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
        </type>
        <type name="Drawable" restrictions="0">
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
            <method name="isAutoScalable" restrictions="8" signature="()Z"/>
        </type>
        <type name="Font" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;J)Lorg/eclipse/swt/graphics/Font;"/>
        </type>
        <type name="FontData" restrictions="0">
            <field name="data" restrictions="8"/>
            <field name="height" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/internal/win32/LOGFONT;F)Lorg/eclipse/swt/graphics/FontData;"/>
        </type>
        <type name="FontMetrics" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/internal/win32/TEXTMETRIC;)Lorg/eclipse/swt/graphics/FontMetrics;"/>
        </type>
        <type name="GC" restrictions="0">
            <method name="getGCData" restrictions="8" signature="()Lorg/eclipse/swt/graphics/GCData;"/>
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Drawable;Lorg/eclipse/swt/graphics/GCData;)Lorg/eclipse/swt/graphics/GC;"/>
            <method name="win32_new" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)Lorg/eclipse/swt/graphics/GC;"/>
        </type>
        <type name="GCData" restrictions="8"/>
        <type name="Image" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
            <field name="type" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;IJ)Lorg/eclipse/swt/graphics/Image;"/>
        </type>
        <type name="ImageData" restrictions="0">
            <method name="internal_new" restrictions="8" signature="(IIILorg/eclipse/swt/graphics/PaletteData;I[BI[B[BIIIIIII)Lorg/eclipse/swt/graphics/ImageData;"/>
        </type>
        <type name="Path" restrictions="0">
            <field name="handle" restrictions="8"/>
        </type>
        <type name="Pattern" restrictions="0">
            <field name="handle" restrictions="8"/>
        </type>
        <type name="Region" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/graphics/Device;I)Lorg/eclipse/swt/graphics/Region;"/>
        </type>
        <type name="TextLayout" restrictions="0">
            <method name="setDefaultTabWidth" restrictions="8" signature="(I)V"/>
        </type>
        <type name="Transform" restrictions="0">
            <field name="handle" restrictions="8"/>
        </type>
    </package>
    <package name="org.eclipse.swt.ole.win32" visibility="1">
        <type name="OleClientSite" restrictions="0">
            <method name="&lt;init&gt;" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Composite;ILjava/lang/String;Ljava/io/File;)V"/>
        </type>
        <type name="OleControlSite" restrictions="0">
            <method name="&lt;init&gt;" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Composite;ILjava/lang/String;Ljava/io/File;)V"/>
        </type>
        <type name="Variant" restrictions="0">
            <method name="win32_copy" restrictions="8" signature="(JLorg/eclipse/swt/ole/win32/Variant;)V"/>
            <method name="win32_new" restrictions="8" signature="(J)Lorg/eclipse/swt/ole/win32/Variant;"/>
        </type>
    </package>
    <package name="org.eclipse.swt.printing" visibility="1">
        <type name="PrintDialog" restrictions="2"/>
        <type name="Printer" restrictions="0">
            <field name="handle" restrictions="8"/>
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
            <method name="isAutoScalable" restrictions="8" signature="()Z"/>
        </type>
    </package>
    <package name="org.eclipse.swt.widgets" visibility="1">
        <type name="Button" restrictions="2"/>
        <type name="Caret" restrictions="2"/>
        <type name="ColorDialog" restrictions="2"/>
        <type name="Combo" restrictions="2"/>
        <type name="Control" restrictions="2">
            <field name="handle" restrictions="8"/>
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
        </type>
        <type name="CoolBar" restrictions="2"/>
        <type name="CoolItem" restrictions="2"/>
        <type name="DateTime" restrictions="2"/>
        <type name="Decorations" restrictions="2"/>
        <type name="DirectoryDialog" restrictions="2"/>
        <type name="Display" restrictions="2">
            <method name="findWidget" restrictions="8" signature="(J)Lorg/eclipse/swt/widgets/Widget;"/>
            <method name="findWidget" restrictions="8" signature="(JJ)Lorg/eclipse/swt/widgets/Widget;"/>
            <method name="findWidget" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Widget;J)Lorg/eclipse/swt/widgets/Widget;"/>
            <method name="internal_dispose_GC" restrictions="8" signature="(JLorg/eclipse/swt/graphics/GCData;)V"/>
            <method name="internal_new_GC" restrictions="8" signature="(Lorg/eclipse/swt/graphics/GCData;)J"/>
            <field name="msg" restrictions="8"/>
            <method name="sendPostExternalEventDispatchEvent" restrictions="8" signature="()V"/>
            <method name="sendPreExternalEventDispatchEvent" restrictions="8" signature="()V"/>
        </type>
        <type name="ExpandBar" restrictions="2"/>
        <type name="ExpandItem" restrictions="2"/>
        <type name="FileDialog" restrictions="2"/>
        <type name="FontDialog" restrictions="2"/>
        <type name="Group" restrictions="2"/>
        <type name="IME" restrictions="2"/>
        <type name="Label" restrictions="2"/>
        <type name="Link" restrictions="2"/>
        <type name="List" restrictions="2"/>
        <type name="Menu" restrictions="2">
            <field name="handle" restrictions="8"/>
        </type>
        <type name="MenuItem" restrictions="2"/>
        <type name="MessageBox" restrictions="2"/>
        <type name="ProgressBar" restrictions="2"/>
        <type name="Sash" restrictions="2"/>
        <type name="Scale" restrictions="2"/>
        <type name="ScrollBar" restrictions="2"/>
        <type name="Scrollable" restrictions="2"/>
        <type name="Shell" restrictions="2">
            <method name="internal_new" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Display;J)Lorg/eclipse/swt/widgets/Shell;"/>
            <method name="win32_new" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Display;J)Lorg/eclipse/swt/widgets/Shell;"/>
        </type>
        <type name="Slider" restrictions="2"/>
        <type name="Spinner" restrictions="2"/>
        <type name="TabFolder" restrictions="2"/>
        <type name="TabItem" restrictions="2"/>
        <type name="Table" restrictions="2"/>
        <type name="TableColumn" restrictions="2"/>
        <type name="TableItem" restrictions="2"/>
        <type name="TaskBar" restrictions="2"/>
        <type name="TaskItem" restrictions="2"/>
        <type name="Text" restrictions="2"/>
        <type name="ToolBar" restrictions="2"/>
        <type name="ToolItem" restrictions="2"/>
        <type name="ToolTip" restrictions="2"/>
        <type name="Tracker" restrictions="2"/>
        <type name="Tray" restrictions="2"/>
        <type name="TrayItem" restrictions="2"/>
        <type name="Tree" restrictions="2"/>
        <type name="TreeColumn" restrictions="2"/>
        <type name="TreeItem" restrictions="2">
            <field name="handle" restrictions="8"/>
        </type>
        <type name="TypedListener" restrictions="0">
            <method name="&lt;init&gt;" restrictions="8" signature="(Lorg/eclipse/swt/internal/SWTEventListener;)V"/>
            <method name="getEventListener" restrictions="8" signature="()Lorg/eclipse/swt/internal/SWTEventListener;"/>
            <method name="handleEvent" restrictions="8" signature="(Lorg/eclipse/swt/widgets/Event;)V"/>
        </type>
        <type name="Widget" restrictions="0">
            <method name="removeListener" restrictions="24" signature="(ILorg/eclipse/swt/internal/SWTEventListener;)V"/>
        </type>
    </package>
</component>
iloveeclipse commented 7 months ago

The last good build is https://download.eclipse.org/eclipse/updates/4.31-I-builds/I20240207-0610/

iloveeclipse commented 7 months ago

@laeubi : which tycho task creates .api_description files in jars? Does it use something from PDE to create that file or it is fully implemented in tycho?

I guess whatever code created that file, it doesn't traverse right directories anymore, may be after 15d3065bc26e206eac005917adb3814b3dd497f7

laeubi commented 7 months ago

It is this one: https://tycho.eclipseprojects.io/doc/latest/tycho-apitools-plugin/generate-mojo.html and it should operate on the compiled classes, source code is here: https://github.com/eclipse-tycho/tycho/blob/main/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiFileGenerationMojo.java

is is basically a wrapper around this: https://github.com/eclipse-pde/eclipse.pde/blob/master/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java

iloveeclipse commented 7 months ago

it should operate on the compiled classes

API descriptions need source code, as they include annotations info from javadoc

laeubi commented 7 months ago

it gets a pointer to the project root and it gets a pointer to the compiled classes ... everything else is handled then by APIFileGenerator.

iloveeclipse commented 7 months ago

I guess it is broken here and can't find source files anymore:

https://github.com/eclipse-pde/eclipse.pde/blob/fb9e44ae186ca0520cb6d125aa9f5dce8e395406/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java#L245

laeubi commented 7 months ago

Looks like one should use <extraSourceLocations> here... what a mess.

laeubi commented 7 months ago

I'll try to take a look, but actually it seems like an SWT issue then, is there already a ticket at SWT?

iloveeclipse commented 7 months ago

With https://github.com/eclipse-pde/eclipse.pde/pull/1191 I see no API errors anymore in SWT (tested on Windows).

iloveeclipse commented 7 months ago

Verified works also on Linux with I20240310-1800 (I've tested original patch on Windows).