Illegal reflective access - Java

I’m sure your devs are already aware, but the following issue occurs in jre10.

The following warning is thrown when executing the java program.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by asposewobfuscated.zzA5 (File:/(...)/Libraries/Aspose/lib/aspose-words-18.5-jdk16.jar) to method java.util.prefs.WindowsPreferences.WindowsRegOpenKey(int,byte[],int)
WARNING: Please consider reporting this to the maintainers of asposewobfuscated.zzA5
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Thanks

@liam.goss,

Is this error document specific? Have you tried latest version of Aspose.Words for Java i.e. 18.5?
https://docs.aspose.com/words/java/installation/
Please share input document, piece of source code and complete steps to reproduce the same issue on our end. Please also share the environment details (OS, JDK versions etc) of the machine you are getting this problem on.

Thanks Awais,
The warning is not document specific.
The error message indicates that I am using version 18.5.
OS windows 7 x64, JDK 10.0.1, eclipse oxygen 4.7.3a
“WARNING: Illegal reflective access by asposewobfuscated.zzA5 (File:/(…)/Libraries/Aspose/lib/aspose-words-18.5-jdk16.jar) to method java.util.prefs.WindowsPreferences.WindowsRegOpenKey(int,byte[],int)”
The code is as follows (simple convert docx to pdf), however I think this error indicates an outdated method call from the Aspose library to the java library. More specifically The method java.util.prefs.WindowsPreferences.WindowsRegOpenKey(int,byte[],int) in class asposewobfuscated.zzA5

public String convertFile(String inFile, String tempDir, String extension)
{
    String Base64 = "";
    try
    {
        Future <String> result = null;
        // make a copy of the file then covert, or convert from the original (original
        // not destroyed).
        boolean copyBeforeConvert = false;
        CallableConverter callable = new CallableConverter(inFile, tempDir, extension, copyBeforeConvert);
        result = executor.submit(callable);
        Base64 = result.get();
        this.convertedCount = convertedCount + 1;
    }
    catch (InterruptedException | ExecutionException e)
    {
        Logit.log(Level.SEVERE, "an error occured whilst converting: " + inFile + " " + e.toString());
    }
    return Base64;
}

Hope this helps.
What version of Java is currently supported as JDK 1.8 is being phased out by January 2019? I see the requirements state 1.8 or above.

@liam.goss,

We will test Aspose.Words for Java with JDK 10.0.1 and share our findings here soon.

Thanks Awais
I only posted the calling code… here is the rest.

public class CallableConverter implements Callable
{
    String inFile, tempDIR, extension;
    boolean copyOriginal;
    public CallableConverter(String inFile, String tempDIR, String extension, boolean copyOrig)
    {
        this.inFile = inFile;
        this.tempDIR = tempDIR;
        this.extension = extension;
        this.copyOriginal = copyOrig;
        
    }
    
    @Override
    public String call() throws Exception
    {
        
        File fileIn = new File(inFile);
        String encoded = null;
        
        if (fileIn.exists())
        {
            
            // Copy the original to temporary location
            String fileName = fileIn.getName();
            Path from = Paths.get(inFile);
            Path to = Paths.get(tempDIR + fileName);
            
            if (this.copyOriginal)
            {
                // use the new file
                Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
            }
            fileIn = to.toFile();
            
            String outFile = null;
            if (to.toString().contains("."))
            {
                String strip = to.toString().substring(0, to.toString().lastIndexOf("."));
                outFile = strip + extension;
                
            } else
            
            {
                outFile = to.toString() + extension;
            }
            
            Document doc = null;
            
            if (this.copyOriginal)
            {
                doc = new Document(fileIn.toString());
            } else
            {
                doc = new Document(from.toString());
            }
            
            doc.save(outFile);
            
            // Read the converted document
            File fileOut = new File(outFile);
            FileStream fs = new FileStream();
            encoded = fs.getBase64(fileOut);
            
            if (fileOut.exists())
            {
                fileIn.delete();
            }
            
            fileIn = null;
            fileOut = null;
            doc = null;
        }
        
        return encoded;
    }
}

@liam.goss,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSJAVA-1785. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for your inconvenience.

Thanks Awais :slight_smile:

Is there an update to this issue? Java 10 is now the only officially supported version of Java, and there is no way of running Aspose without our users getting this error.

@Steve_S,

WORDSJAVA-1785 has now been resolved. The fix of this issue will be included in the next 18.8 version of Aspose.Words. We will inform you via this thread as soon as next version of Aspose.Words containing the fix of this issue will be released by the end of next week.

The issues you have found earlier (filed as WORDSJAVA-1785) have been fixed in this Aspose.Words for .NET 18.8 update and this Aspose.Words for Java 18.8 update.