question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find symbols

See original GitHub issue

I try to add some extend methods to org.springframework.http.server.reactive.ServerHttpRequest and got compile error cannot find symbols.

step 1

everything is ok.

@Extension
public class ServerHttpRequestExt {
  public static void helloWorld(@This ServerHttpRequest thiz) {
    System.out.println("hello world!");
  }
}

step 2

use ManCharSequenceExt.isNullOrEmpty in package manifold.text.extensions.java.lang.CharSequence of manifold-text so add dependency in pom.xml:

<dependencies>
    <dependency>
        <groupId>systems.manifold</groupId>
        <artifactId>manifold-text</artifactId>
        <version>2021.1.34</version>
    </dependency>
</dependencies>

then got error:

@Extension
public class ServerHttpRequestExt {
  public static void helloWorld(@This ServerHttpRequest thiz, String hello) {
    // cannot find symbols
    if (hello.isNullOrEmpty()) {
      System.out.println("bye!");
    }
    System.out.println("hello " + hello + "!");
  }
}

step 3

add maven-compiler-plugin with some configurations:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>8</source>
        <target>8</target>
        <encoding>UTF-8</encoding>
        <compilerArgs>
            <!-- Configure manifold plugin -->
            <arg>-Xplugin:Manifold no-bootstrap</arg>
        </compilerArgs>
        <!-- Add the processor path for the plugin -->
        <annotationProcessorPaths>
            <path>
                <groupId>systems.manifold</groupId>
                <artifactId>manifold-ext</artifactId>
                <version>${manifold.version}</version>
            </path>
            <path>
                <groupId>systems.manifold</groupId>
                <artifactId>manifold-text</artifactId>
                <version>${manifold.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

got compile error but not same position:


import manifold.ext.rt.api.Extension;
import manifold.ext.rt.api.This;
// cannot find symbols
import org.springframework.http.server.reactive.ServerHttpRequest;


@Extension
public class ServerHttpRequestExt {
  // cannot find symbols
  public static void helloWorld(@This ServerHttpRequest thiz, String hello) {
    if (hello.isNullOrEmpty()) {
      System.out.println("bye!");
    }
    System.out.println("hello " + hello + "!");
  }
}

sample project

here’s a sample

versions

manifold: 2021.1.34 idea: 2021.1.3 maven: 3.6.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
xkyiicommented, Jan 3, 2022

Based on your suggestion, it worked perfectly and I may have missed something else to check. Thanks a million and Happy New Year 🎉

0reactions
rsmckinneycommented, Jan 1, 2022

Yes, that is odd. Manifold definitely works with any Java version 8 or greater. I made a straightforward project based on your examples that demonstrates this. I suggest you start over with a cleaner project based on this one. Happy New Year!

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>spring-example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <manifold.version>2021.1.36</manifold.version>
        <spring-boot.version>2.6.2</spring-boot.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>systems.manifold</groupId>
            <artifactId>manifold-ext-rt</artifactId>
            <version>${manifold.version}</version>
        </dependency>
        <dependency>
            <groupId>systems.manifold</groupId>
            <artifactId>manifold-text</artifactId>
            <version>${manifold.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <encoding>UTF-8</encoding>
                    <compilerArgs>
                        <!-- Configure manifold plugin -->
                        <arg>-Xplugin:Manifold no-bootstrap</arg> 
                    </compilerArgs>
                    <!-- Add the processor path for the plugin -->
                    <annotationProcessorPaths>
                        <path>
                            <groupId>systems.manifold</groupId>
                            <artifactId>manifold-ext</artifactId>
                            <version>${manifold.version}</version>
                        </path>
                        <path>
                            <groupId>systems.manifold</groupId>
                            <artifactId>manifold-text</artifactId>
                            <version>${manifold.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <!--class files as source must be available for extension method classes-->
                            <Contains-Sources>java,class</Contains-Sources>
                            <!--JPMS module name-->
                            <Automatic-Module-Name>spring.example</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Resolve The Cannot Find Symbol Error in Java - Rollbar
As its name implies, the cannot find symbol error refers to a symbol which cannot be found. While there are multiple ways and...
Read more >
java - What does a "Cannot find symbol" or "Cannot resolve ...
A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler...
Read more >
What can cause the "cannot find symbol" error in Java?
The “cannot find symbol” error occurs mainly when we try to reference a variable that is not declared in the program which we...
Read more >
"Cannot Find Symbol" compile error - Net-Informations.Com
The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error...
Read more >
What Causes “Cannot find symbol” Compilation Error in Java?
As the name suggests, the Java cannot find symbol error occurs when a required symbol cannot be found in the symbol table. Although...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found