If the definition has changed, it’s going to appear to Java to be a different 
method, and you won’t be able to call it, any more than you can call any method 
that no longer exists. That’s the challenge with working with very old code. 
Deprecation typically only gives you flexibility to move one or two JDK 
versions.

So your options are pretty much: change the code to match the current API, or 
run against an old JDK.

> On Jul 26, 2020, at 10:53 PM, Amit Mathapati <amitmathap...@gmail.com> wrote:
> 
> 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 
> <mailto: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 <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:
> 
> Passing in null values for ClassLoaded and ProtectionDomain
> 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?
> 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?
> 
> <pom.xml>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to