Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eclipse annotation processor package crash #439

Open
zeroinformatique opened this issue Oct 8, 2023 · 0 comments
Open

Eclipse annotation processor package crash #439

zeroinformatique opened this issue Oct 8, 2023 · 0 comments

Comments

@zeroinformatique
Copy link

In Eclipse 2023-09, with Gradle and the IDE annotation processor, ToothPick 3.10.
I get this error:

Java Model Exception: Error in Java Model (code 983): Invalid name specified: package org.xxx

!ENTRY org.eclipse.jdt.apt.core 4 1 2023-10-08 17:01:07.265
!MESSAGE invalid name for package:package org.xxx
!STACK 1
org.eclipse.core.runtime.CoreException: Paths must not be null.
	at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager.generateFileDuringBuild(GeneratedFileManager.java:543)
	at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeJavaSourceOutputStream.close(IdeJavaSourceOutputStream.java:71)
	at java.base/sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:347)
	at java.base/sun.nio.cs.StreamEncoder.close(StreamEncoder.java:169)
	at java.base/java.io.OutputStreamWriter.close(OutputStreamWriter.java:252)
	at java.base/java.io.BufferedWriter.close(BufferedWriter.java:269)
	at java.base/java.io.PrintWriter.close(PrintWriter.java:415)
	at toothpick.compiler.common.ToothpickProcessor.writeToFile(ToothpickProcessor.java:147)
	at toothpick.compiler.factory.FactoryProcessor.process(FactoryProcessor.java:124)

This seems related to this issue in Eclipse:

It comes down to the processor misusing the javax.lang.model: calling Package.toString() returns the qualified name in javac, but returns 'package qualifiedName' in Eclipse! So in Eclipse we attempt to place our generated sources in package 'package com.somewhere.generated' which of course is not valid.

The fix is easy: change getPackage().toString() to getPackage().getQualifiedName().toString() in your annotation processor and the issue vanishes. This is therefore not an Eclipse bug, but rather an implementation difference. (it does not appear that toString is specified particularly in this case)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=540765

ToothPick doesn't work properly on Eclipse because of this Package name issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant