Bug 127015 - Warnings when trying Beanshell + OpenJdk11
Summary: Warnings when trying Beanshell + OpenJdk11
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-18 20:41 UTC by Julien Nabet
Modified: 2021-08-20 08:04 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Nabet 2019-08-18 20:41:08 UTC
Description:
On pc Debian x86-64 with master sources updated today + OpenJDK 11, I got these logs on console:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.star.script.framework.container.XMLParserFactory$DefaultParser (file:/home/julien/lo/libreoffice/instdir/program/../program/classes/ScriptFramework.jar) to method com.sun.org.apache.xml.internal.serialize.OutputFormat.setMethod(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.sun.star.script.framework.container.XMLParserFactory$DefaultParser
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
when creating a macro in BeanShell part

Steps to Reproduce:
1. Launch LO
2. Tools/Macros/Organize Macros/BeanShell...
3. Select "Untitled 1" doc + click "Create..."

The macro seems created but logs quoted display

click on the macro

Actual Results:
"Edit" button is disabled
+ warnings on console just before when creating the macro

Expected Results:
No warning when creating the macro
Edit button enabled


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Oliver Brinzing 2019-08-19 07:07:43 UTC
seems, com.sun.org.apache.xml.internal.serialize.OutputFormat is deprecated:

https://java-browser.yawk.at/java/10/java.xml/com/sun/org/apache/xml/internal/serialize/OutputFormat.java#com.sun.org.apache.xml.internal.serialize.OutputFormat
Comment 2 Julien Nabet 2019-08-19 07:35:53 UTC
code pointer: https://opengrok.libreoffice.org/xref/core/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java?r=0063cf28#113

Olivier: you're right but we got to deal with Java versions.

Stephan: I re read https://www.libreoffice.org/get-help/system-requirements/, if 
Java is indicated as prerequisite for Base mainly, minimum version isn't indicated.
Searching in git history, I found your commit https://cgit.freedesktop.org/libreoffice/core/commit/?id=aafc10c9edb61e13ac557c7e43c8d4a31dce4f37. If I well understood, until 6.3 included, min Java version would be 1.6 and from future 6.4.0, it'll be 1.8
Any idea about a mechanism to deal from Java 6 until OpenJDK 11?
Comment 3 Oliver Brinzing 2019-08-19 12:35:36 UTC
reproducible with:

Version: 6.4.0.0.alpha0+ (x64)
Build ID: 082e95f684e44954275dc58e306b8dc69590ac80
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: threaded

IMHO the XMLSerializer class instantiation via introspection has to be replaced, cause Java 9 does not allow it anymore.
Comment 4 Julien Nabet 2019-08-19 12:43:35 UTC
(In reply to Oliver Brinzing from comment #3)
> ...
> IMHO the XMLSerializer class instantiation via introspection has to be
> replaced, cause Java 9 does not allow it anymore.

It seems LSSerializer may be used even with Java6, https://www.doc.ic.ac.uk/csg-old/java/jdk6docs/api/org/w3c/dom/ls/LSSerializer.html
Comment 5 Julien Nabet 2019-08-19 14:34:57 UTC
I'm not sure but it seems that with LSSerializer, we can avoid using formatterClass and just keep serializerClass. Perhaps we can remove the try/catch and avoid the introspection and plainly use LSSerializer.
Comment 6 Julien Nabet 2019-08-19 14:50:56 UTC
(In reply to Julien Nabet from comment #5)
> I'm not sure but it seems that with LSSerializer, we can avoid using
> formatterClass and just keep serializerClass. Perhaps we can remove the
> try/catch and avoid the introspection and plainly use LSSerializer.
I meant "LSSerializerImpl" since "LSSerializer" is just an interface.

Now the problem is I don't know how to use this class since import don't work.
I searched how to import to avoid all the introspection stuff (it's quite ugly and I suppose it doesn't help for speed) but failed.

I must recognize I'm stuck.
Comment 7 Stephan Bergmann 2019-08-19 15:30:27 UTC
(In reply to Julien Nabet from comment #0)
> Steps to Reproduce:
> 1. Launch LO
> 2. Tools/Macros/Organize Macros/BeanShell...
> 3. Select "Untitled 1" doc + click "Create..."

...which opens a "Create Library" dialog that asks for a name, with "Library1" already suggested, so press "OK"; then click on the triangle to the left of "Untitled 1" to expand it, then click on "Library1", then click "Create..." which opens a "Create Macro" dialog that asks for a name, with "Macro1" already suggested, so press "OK"; then click on the triangle to the left of "Library1" to expand it, then click on "Macro1.bsh", then click on "Edit" which is now enabled.

> The macro seems created but logs quoted display
> 
> click on the macro
> 
> Actual Results:
> "Edit" button is disabled

See above.  Looks like you didn't follow all those steps that are required to edit a new macro?

> + warnings on console just before when creating the macro

Those are apparently only warnings for now (i.e., with Java 11, and also tested now with OpenJava 12.0.2 where it's still only a warning).  That leaves us some more time to come up with a fix eventually.  :)
Comment 8 Oliver Brinzing 2019-08-19 15:41:06 UTC
(In reply to Julien Nabet from comment #6)
> Now the problem is I don't know how to use this class since import don't
> work.
> I searched how to import to avoid all the introspection stuff (it's quite
> ugly and I suppose it doesn't help for speed) but failed.
 
maybe something like this can help:

import java.io.StringWriter;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.DOMStringList;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer;

public class LSSerialize {

	public static void main(String[] args) throws Exception {

		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder = factory.newDocumentBuilder();
		Document document = builder.newDocument();

		Node n = document.appendChild(document.createElement("Hello"));
		n.appendChild(document.createElement("World"));

		DOMImplementation impl = document.getImplementation();
		DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
		LSSerializer dsi = implLS.createLSSerializer();

		DOMConfiguration dc = dsi.getDomConfig();

		DOMStringList params = dc.getParameterNames();
		for (int i = 0; i < params.getLength(); i++) {
			System.out.println(params.item(i));
		}

		dc.setParameter("well-formed", true);
		dc.setParameter("format-pretty-print", true);
		dc.setParameter("xml-declaration", true);

		LSOutput lsOutput = implLS.createLSOutput();
		lsOutput.setEncoding("UTF-8");

		StringWriter stringWriter = new StringWriter();
		lsOutput.setCharacterStream(stringWriter);
		dsi.write(document, lsOutput);
		System.out.println("\n" + stringWriter.toString());

	}
}
Comment 9 Julien Nabet 2019-08-19 15:45:38 UTC
(In reply to Stephan Bergmann from comment #7)
> ...
> See above.  Looks like you didn't follow all those steps that are required
> to edit a new macro?
> ...
Yes I saw this on Win10, I wanted to retest tonight on my Linux computer

> > + warnings on console just before when creating the macro
> 
> Those are apparently only warnings for now (i.e., with Java 11, and also
> tested now with OpenJava 12.0.2 where it's still only a warning).  That
> leaves us some more time to come up with a fix eventually.  :)
Yes and when 6.3 will be EOL, we'll be able to deal with Java from 1.8 instead of 1.6
Comment 10 Julien Nabet 2019-08-20 08:58:01 UTC
Stephan: I changed the title of the bugtracker, should we keep this one opened or should we close it?
Comment 11 Stephan Bergmann 2019-08-20 09:12:21 UTC
(In reply to Julien Nabet from comment #10)
> Stephan: I changed the title of the bugtracker, should we keep this one
> opened or should we close it?

Lets keep it open.  We will need a fix once that warning is turned into an error in a future version of Java.  (Using LSSerializer as discussed in earlier comments here looks like a good way to go.)
Comment 12 QA Administrators 2021-08-20 03:52:05 UTC Comment hidden (obsolete)
Comment 13 Julien Nabet 2021-08-20 08:04:41 UTC
With master sources updated today, I don't have these logs anymore, just the usual:
warn:i18nlangtag:7779:7779:i18nlangtag/source/languagetag/languagetag.cxx:1648: LanguageTag::getRegionFromLangtag: pRegionT==NULL for 'eo-EO'
warn:i18nlangtag:7779:7779:i18nlangtag/source/languagetag/languagetag.cxx:1648: LanguageTag::getRegionFromLangtag: pRegionT==NULL for 'eo-EO'
warn:sal.osl:7779:7779:sal/osl/unx/module.cxx:155: dlopen(/home/julien/lo/libreoffice/instdir/program/libjava_gcc3.so, 257): /home/julien/lo/libreoffice/instdir/program/libjava_gcc3.so: cannot open shared object file: No such file or directory
warn:sal.osl:7779:7779:sal/osl/unx/module.cxx:155: dlopen(/home/julien/lo/libreoffice/instdir/program/libgcc3_java.so, 257): /home/julien/lo/libreoffice/instdir/program/libgcc3_java.so: cannot open shared object file: No such file or directory

Remark: "Edit" button is still disabled.

Since the bug concerned only logs, let's put this one to WFM then.
If you want to reopen it for "Edit" part, don't hesitate of course.