My bad, I had forgotten to attach my pom.xml file.


On Sun, Jul 26, 2020 at 7:47 PM Amit Mathapati <amitmathap...@gmail.com>
wrote:

>
>
> <https://stackoverflow.com/posts/63105213/timeline>
>
> Hello Users,
>
>
> I am trying to modify an mvel2 library open source code dating back from <
> 2010. https://github.com/mvel/mvel
>
> THis is a maven project.
>
> I recently downloaded the source code and when I tried to compile the
> project, it gives an error message.
>
> public Class<?> defineClassX(String className, byte[] b, int off, int len) {
>         if (sunJVM) {
>             return ((Unsafe) sunUnsafe).defineClass(className, b, off, len);
>         }
>         else {
>             return super.defineClass(className, b, off, len);
>         }
>     }
>
> Error message: Error:(59,40) java: method defineClass in class 
> sun.misc.Unsafe cannot be applied to given types;
>
> mvel2 2.0.16 seems to have built with Java 1.5 but in my recent
> environment it is Java 1.8 and the "defineClass" method definition has
> changed.
>
> New Method definition in Java 1.8 :
>
> public native Class<?> defineClass(String var1, byte[] var2, int var3, int 
> var4, ClassLoader var5, ProtectionDomain var6);
>
> What is the workaround for this?
>
> Some options I tried:
>
>    1.
>
>    Passing in null values for ClassLoaded and ProtectionDomain
>    2.
>
>    in pom.xml, under:
>
>     <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>3.6.2</version>
>                 <configuration>
>                     <source>1.6</source>
>                     <target>1.6</target>
>                     <encoding>UTF-8</encoding>
>                     <compilerArgs>
>                         <compilerArg>-XDignore.symbol.file</compilerArg>
>                     </compilerArgs>
>                 </configuration>
>             </plugin>
>
>       a) I tried passing in 1.5 but it fails with same error
>       b) Tried the compilerArgs but no luck either?
>
>
>    1. Tip from VGR below in the comments to remove the if(sunJVM) block
>    causes all test cases to fail when building the maven package.
>
> I feel the issue seems to be that, since the source code package was built
> with Java 1.5 and now since I am building with the latest Java 1.8 version,
> it is failing.
>
> Can someone suggest a workaround for this?
>
<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/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mvel</groupId>
    <artifactId>mvel2</artifactId>
    <packaging>jar</packaging>
    <version>2.0.16-LKDN</version>
    <name>mvel</name>
    <url>http://mvel.codehaus.org/</url>

    <scm>
        <developerConnection>scm:svn:https://svn.codehaus.org/mvel/tags/mvel2-2.0.16</developerConnection>
    </scm>

    <pluginRepositories>
        <pluginRepository>
            <id>apache-snapshots</id>
            <name>Apache Snapshot Repository</name>
            <url>http://repository.apache.org/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>

    </pluginRepositories>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-webdav</artifactId>
                <version>1.0-beta-2</version>
            </extension>
        </extensions>


        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.mvel2.sh.Main</mainClass>
                            <packageName>org.mvel2</packageName>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId
                <configuration>
                    <childDelegation>true</childDelegation>
                    <systemProperties>
                        <property>
                            <name>mvel.disable.jit</name>
                            <value>true</value>
                        </property>
                        <property>
                            <name>file.encoding</name>
                            <value>UTF-8</value>
                        </property>
                    </systemProperties>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                        <include>**/UsageDemos.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/CompiledUnitTestEx.java</exclude>
                        <exclude>**/PerfTest.java</exclude>
                        <exclude>**/DroolsTest.java</exclude>
                        <exclude>**/FailureTests.java</exclude>
                        <exclude>**/PerformanceTest.java</exclude>
                        <exclude>**/CompiledPerformanceTests.java</exclude>
                        <exclude>**/MVELThreadTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.0-beta-9</version>
                <configuration>
                    <tagBase>https://svn.codehaus.org/mvel/tags/</tagBase>
                    <!-- See http://jira.codehaus.org/browse/SCM-406 -->
                    <remoteTagging>false</remoteTagging>
                    <!-- Further non-mandatory but useful settings... -->
                    <preparationGoals>clean install</preparationGoals>
                    <autoVersionSubmodules>true</autoVersionSubmodules>

                </configuration>
            </plugin>

            <plugin>
              <artifactId>maven-jar-plugin</artifactId>
              <configuration>
                <archive>
                  <manifestFile>META-INF/MANIFEST.MF</manifestFile>
                </archive>
              </configuration>
            </plugin>

			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.0.1</version>
				<extensions>true</extensions>
				<executions>
					<execution>
						<id>manifest</id>
						<phase>process-classes</phase>
						<goals>
							<goal>manifest</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
                    <manifestLocation>META-INF</manifestLocation>
					<instructions>
                        <Bundle-SymbolicName>org.mvel2</Bundle-SymbolicName>
                        <Bundle-Name>mvel2</Bundle-Name>
					</instructions>

				</configuration>
			</plugin>
        </plugins>
    </build>


    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.3.1</version>
            <scope>test</scope>
        </dependency>

        <!--<dependency>-->
        <!--<groupId>org.hibernate</groupId>-->
        <!--<artifactId>ejb3-persistence</artifactId>-->
        <!--<version>1.0.2.GA</version>-->
        <!--<scope>test</scope>-->
        <!--</dependency>        -->
    </dependencies>


    <distributionManagement>
        <!-- use the following if you're not using a snapshot version. -->
        <repository>
            <id>codehaus.org</id>
            <name>Codehaus Maven Repository</name>
            <url>dav:https://dav.codehaus.org/repository/mvel/</url>
        </repository>
        <!-- use the following if you ARE using a snapshot version. -->
        <snapshotRepository>
            <id>codehaus.org</id>
            <name>Codehaus Snapshot Maven Repository</name>
            <url>dav:https://dav.codehaus.org/snapshots.repository/mvel/</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to