Stamatis Zampetakis created CALCITE-5300:
--------------------------------------------
Summary: Cannot access org.immutables.value.Value error when
extending standard rules
Key: CALCITE-5300
URL: https://issues.apache.org/jira/browse/CALCITE-5300
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.32.0
Environment: Tested with JDK 8, 11, 17, 19
Reporter: Stamatis Zampetakis
A compilation error is raised when a project depends on calcite-core (version
1.28.0 onwards) and log4j2-core and there is a custom rule extending some
standard rule from Calcite, which uses the [Immutables
library](https://immutables.github.io/) {{@Value}} annotation.
The error is the following:
{noformat}
[ERROR] cannot access org.immutables.value.Value
[ERROR] class file for org.immutables.value.Value not found
{noformat}
To reproduce the problem it suffices to do the following.
1. Create a maven project with the following dependencies:
{noformat}
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>1.32.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
{noformat}
2. Write a rule that extends some standard rule from Calcite.
{code:java}
import org.apache.calcite.rel.rules.ProjectMergeRule;
public class MyProjectMergeRule extends ProjectMergeRule {
public MyProjectMergeRule(Config config) {
super(config);
}
}
{code}
3. Compile the project
{code:java}
mvn clean install
{code}
The problem is not dependent to a specific JDK or maven version but does
require log4j-core to be in the classpath; log4j-core has an annotation
processor and this somehow triggers the problem when the annotations are not in
the classpath (LOG4J2-3609).
Calcite does not declare the immutable annotations as an implementation
dependency thus the annatations are not present in (the classpath of) 3rd party
projects depending on calcite-core.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)