jzy3d-api icon indicating copy to clipboard operation
jzy3d-api copied to clipboard

ChartFactory.newChart is not API

Open Mailaender opened this issue 2 years ago • 6 comments

Describe the bug

When importing via @eclipse-m2e I get an error at this line

Chart chart = chartFactorySWT.newChart(quality);
Access restriction: The method 'ChartFactory.newChart(Quality)' is not API (restriction on required library '~/Eclipse/rcp-2022-03/eclipse/configuration/org.eclipse.osgi/291/data/f2c50ff5598514905948ed0f33983d582e6a69e5/org.jzy3d/jzy3d-core/2.0.1-SNAPSHOT/jzy3d-core-2.0.1-SNAPSHOT.jar')

It seems that an OSGi environment requires this to be exported.

Reproducibility Add this to your .target platform:

<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-native-jogl-swt</artifactId>
				<version>2.0.1-SNAPSHOT</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-snapshots</id>
				<url>https://maven.jzy3d.org/snapshots/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-core</artifactId>
				<version>2.0.1-SNAPSHOT</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-snapshots</id>
				<url>https://maven.jzy3d.org/snapshots/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-core-swt</artifactId>
				<version>2.0.1-SNAPSHOT</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-snapshots</id>
				<url>https://maven.jzy3d.org/snapshots/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-api</artifactId>
				<version>1.0.3-SNAPSHOT</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-snapshots</id>
				<url>https://maven.jzy3d.org/snapshots/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jogamp.jogl</groupId>
				<artifactId>jogl-all</artifactId>
				<version>2.3.2</version>
				<type>jar</type>
			</dependency>
		</dependencies>
	</location>

This won't compile:

public class Plot3D extends Composite {

	public Plot3D(Composite parent, int style) {

		super(parent, style);
	
		SWTChartFactory chartFactorySWT = new SWTChartFactory(parent);
		Quality quality = Quality.Advanced();
		quality.setHiDPIEnabled(false);
		Chart chart = chartFactorySWT.newChart(quality);
	}
}

Versions (please complete the following information):

  • Jzy3D: 2.0.1
  • JVM / JDK: Temurin 11
  • GPU: NVIDIA Geforce GT 640
  • OS: KDE Neon

Additional context #89

Mailaender avatar May 02 '22 08:05 Mailaender

There is something weird in your configuration with a reference to maven module jzy3d-api:1.0.3-SNAPSHOT. This module has disappeared as of 2.0. Also, if you are willing to work with the current SNAPSHOT version, you should not see JOGL 2.3.2 in your configuration but rather JOGL 2.4-rc4.

You should probably re-generate your Eclipse project files (or check if your Maven pom as consistent references to Jzy3D)

jzy3d avatar May 02 '22 08:05 jzy3d

Removing the -api package and downgrading to the release snapshot:

	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-native-jogl-swt</artifactId>
				<version>2.0.0</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-releases</id>
				<url>https://maven.jzy3d.org/releases/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-core</artifactId>
				<version>2.0.0</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-releases</id>
				<url>https://maven.jzy3d.org/releases/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jzy3d</groupId>
				<artifactId>jzy3d-core-swt</artifactId>
				<version>2.0.0</version>
				<type>jar</type>
			</dependency>
		</dependencies>
		<repositories>
			<repository>
				<id>jzy3d-releases</id>
				<url>https://maven.jzy3d.org/releases/</url>
			</repository>
		</repositories>
	</location>
	<location includeDependencyDepth="none" includeSource="true" missingManifest="generate" type="Maven">
		<dependencies>
			<dependency>
				<groupId>org.jogamp.jogl</groupId>
				<artifactId>jogl-all</artifactId>
				<version>2.3.2</version>
				<type>jar</type>
			</dependency>
		</dependencies>
	</location>

reveals the same error:

Access restriction: The method 'ChartFactory.newChart(Quality)' is not API (restriction on required library '~/Eclipse/rcp-2022-03/eclipse/configuration/org.eclipse.osgi/291/data/f2c50ff5598514905948ed0f33983d582e6a69e5/org.jzy3d/jzy3d-core/2.0.0/jzy3d-core-2.0.0.jar')

I don't understand why it is this particular function and nothing else.

Mailaender avatar May 02 '22 08:05 Mailaender

The method really is part of the API in 2.0.0 (and 2.0.1).

This fix looks weird but is worth trying. Maybe Eclipse did no rebuilt things since you remove references to 1.0.3?

jzy3d avatar May 02 '22 09:05 jzy3d

I was hoping for something like https://github.com/jamesmudd/jhdf/pull/367 but I don't see where you export packages and create this metadata.

Mailaender avatar May 02 '22 09:05 Mailaender

I haven't done this. Reading the discussion you mentioned shows that the proposal finally was implemented somewhere else.

The Maven Jar Plugin is already in the main pom file. Maybe we can use it to add the key/values required by OSGi in the manifest file?

jzy3d avatar May 02 '22 09:05 jzy3d

I tried to follow the instructions at https://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html but that so far only lead to unit tests fail.

Mailaender avatar May 02 '22 12:05 Mailaender