Bug 182960 - Editing Java Class template activates Java ME
Editing Java Class template activates Java ME
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Templates
6.x
All All
: P2 (vote)
: 7.1
Assigned To: Jaroslav Tulach
issues@platform
: ERGONOMICS
: 185545 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-03-26 19:46 UTC by _ tboudreau
Modified: 2011-11-09 16:09 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Thread dump (14.09 KB, text/plain)
2010-03-26 19:58 UTC, _ tboudreau
Details
java.source, openide.loaders and libs.freemarker (2.62 KB, patch)
2011-10-08 20:07 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2010-03-26 19:46:40 UTC
I just opened Tools > Templates, selected Java > Java Class and chose Open In Editor.

A dialog appeared "Activating Java ME" and the activation of a large number of modules was logged (see below).

This seems like a weird and unnecessary entry-point.  Looking in Tools > Plugins now, this caused *everything* to be activated - Ruby, Groovy, Java ME, PHP.

INFO [org.netbeans.core.startup.NbEvents]: Turning on modules:
	org.netbeans.modules.mobility.licensing [1.7 100318-213962348040]
	org.netbeans.api.mobility [8.7 100318-213962348040]
	org.netbeans.modules.mobility.cldcplatform [1.9 100318-213962348040]
	org.netbeans.modules.j2ee.dd.webservice [1.13 100318-213962348040]
	org.netbeans.modules.websvc.jaxwsmodel/1 [1.10 100318-213962348040]
	org.netbeans.modules.websvc.jaxwsapi [1.8 100318-213962348040]
	org.netbeans.modules.websvc.websvcapi [1.13 100318-213962348040]
	org.netbeans.modules.websvc.wsstackapi/0 [1.5 100318-213962348040]
	org.netbeans.modules.j2ee.common/1 [1.49 100318-213962348040]
	org.netbeans.modules.websvc.restapi/0 [1.5 100318-213962348040]
	org.netbeans.modules.websvc.utilities/0 [1.7 100318-213962348040]
	org.netbeans.modules.websvc.wsstack.jaxws/0 [1.5 100318-213962348040]
	org.netbeans.modules.websvc.projectapi/0 [1.4 100318-213962348040]
	org.netbeans.modules.websvc.clientapi [1.13 100318-213962348040]
	org.netbeans.modules.websvc.core [1.16.0.1.4 1 100318-213962348040]
	org.netbeans.modules.websvc.editor.hints [1.8 100318-213962348040]
	org.netbeans.modules.servletjspapi/1 [1.8.0.25 25 100318-213962348040]
	org.netbeans.libs.glassfish_logging/1 [1.8.0.20 20 100318-213962348040]
	org.netbeans.modules.web.jspparser/3 [3.7 100318-213962348040]
	org.netbeans.modules.web.project [1.23.0.1 1 100318-213962348040]
	org.netbeans.modules.websvc.manager [1.7 100318-213962348040]
	org.netbeans.modules.websvc.wsitmodelext [3.9 100318-213962348040]
	org.netbeans.modules.websvc.jaxws.lightapi [1.4 100318-213962348040]
	org.netbeans.modules.websvc.design [1.7 100318-213962348040]
	org.netbeans.modules.websvc.wsitconf [3.10 100318-213962348040]
	org.netbeans.modules.websvc.metro.samples/1 [1.8 100318-213962348040]
	org.netbeans.modules.websvc.customization [1.8.0.2 100318-213962348040]
	org.netbeans.modules.web.debug/1 [2.17 100318-213962348040]
	org.netbeans.modules.web.beans/1 [1.4 100318-213962348040]
	org.netbeans.modules.web.examples/1 [1.14 100318-213962348040]
	org.netbeans.modules.j2ee.samples [1.9 100318-213962348040]
	org.netbeans.modules.web.monitor/1 [1.24 100318-213962348040]
	org.netbeans.modules.j2ee.ant [1.16.0.1 100318-213962348040]
	org.netbeans.modules.javaee.api [1.3 100318-213962348040]
	org.netbeans.modules.j2ee.ejbcore [1.16 100318-213962348040]
	org.netbeans.modules.j2ee.ddloaders/1 [1.15.0.2 100318-213962348040]
	org.netbeans.modules.j2ee.weblogic9/1 [1.15 100318-213962348040]
	org.netbeans.modules.j2ee.jboss4/1 [1.16 100318-213962348040]
	org.netbeans.modules.el.lexer/1 [1.8 100318-213962348040]
	org.netbeans.modules.jsp.lexer/1 [1.8 100318-213962348040]
	org.netbeans.modules.web.core.syntax/2 [2.10.0.2.6 2 100318-213962348040]
	org.netbeans.modules.web.core/2 [2.9.0.43.2 43 100318-213962348040]
	org.netbeans.modules.web.freeform [1.13 100318-213962348040]
	org.netbeans.modules.j2ee.sun.dd/1 [1.14.0.1 1 100318-213962348040]
	org.netbeans.modules.glassfish.eecommon/0 [1.5.0.1.1 1 100318-213962348040]
	org.netbeans.modules.glassfish.javaee/0 [1.4 100318-213962348040]
	org.netbeans.modules.web.helpset/0 [1.4 100318-213962348040]
	org.netbeans.modules.web.jstl11/1 [2.15.0.112 112 100318-213962348040]
	org.netbeans.modules.j2ee.genericserver [1.13 100318-213962348040]
	org.netbeans.modules.tomcat5/1 [1.17 100318-213962348040]
	org.netbeans.modules.j2ee.sun.appsrv/1 [1.14.0.1 1 100318-213962348040]
	org.netbeans.modules.j2ee.sun.ddui/1 [1.15.0.1.1 1 100318-213962348040]
	org.netbeans.modules.j2ee.sun.appsrv81/1 [1.11.0.1 1 100318-213962348040]
	org.netbeans.modules.web.refactoring [1.8.0.43 100318-213962348040]
	org.netbeans.modules.web.kit [1.7 100318-213962348040]
	org.netbeans.modules.websvc.metro.model [1.4 100318-213962348040]
	org.netbeans.modules.websvc.metro.lib/1 [1.10 100318-213962348040]
	org.netbeans.modules.websvc.kit [1.7 100318-213962348040]
	org.netbeans.mobility.lib.activesync/1 [1.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform [1.8 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.semc [1.7 100318-213962348040]
	org.netbeans.modules.vmd.model [1.7 100318-213962348040]
	org.netbeans.modules.vmd.io [1.8 100318-213962348040]
	org.netbeans.modules.vmd.analyzer [1.7 100318-213962348040]
	org.netbeans.modules.vmd.codegen [1.7 100318-213962348040]
	org.netbeans.modules.vmd.palette [1.8 100318-213962348040]
	org.netbeans.modules.mobility.antext [1.9 100318-213962348040]
	org.netbeans.modules.mobility.project.bridge [1.5 100318-213962348040]
	org.netbeans.modules.mobility.project [1.11 100318-213962348040]
	org.netbeans.modules.mobility.editor [1.12 100318-213962348040]
	org.netbeans.modules.vmd.io.javame [1.7 100318-213962348040]
	org.netbeans.modules.vmd.flow [1.7 100318-213962348040]
	org.netbeans.modules.vmd.screen [1.7 100318-213962348040]
	org.netbeans.modules.vmd.properties [1.7 100318-213962348040]
	org.netbeans.modules.vmd.inspector [1.7 100318-213962348040]
	org.netbeans.modules.vmd.midp [1.8 100318-213962348040]
	org.netbeans.modules.mobility.cldcplatform.catalog [1.8 100318-213962348040]
	org.netbeans.modules.mobility.project.ant [1.5 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.ricoh [1.7 100318-213962348040]
	org.netbeans.libs.aguiswinglayout [1.7 100318-213962348040]
	org.netbeans.libs.commons_fileupload/1 [1.7 100318-213962348040]
	org.netbeans.modules.web.struts/1 [1.13.0.1 1 100318-213962348040]
	org.netbeans.modules.identity.profile.api [1.9 100318-213962348040]
	org.netbeans.modules.identity.server.manager/1 [1.9 100318-213962348040]
	org.netbeans.modules.identity.profile.ui [1.8 100318-213962348040]
	org.netbeans.libs.jakarta_oro/1 [1.6.0.208 208 100313-766866f3b922]
	org.netbeans.libs.commons_net/1 [1.7.0.141 141 100313-766866f3b922]
	org.netbeans.modules.mobility.deployment.ftpscp [1.8 100318-213962348040]
	org.netbeans.modules.svg.perseus [1.8 100318-213962348040]
	org.netbeans.modules.mobility.svgcore [1.9 100318-213962348040]
	org.netbeans.modules.vmd.midpnb [1.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.execui [1.5 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project [1.8 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.semc [1.7 100318-213962348040]
	org.netbeans.modules.vmd.components.svg/2 [1.8 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.sjmc [1.5 100318-213962348040]
	org.netbeans.modules.mvd/2 [1.8 100318-213962348040]
	org.netbeans.modules.apisupport.facebooksample [1.0 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.sun [1.7 100318-213962348040]
	org.netbeans.modules.mobility.midpexamples [1.9 100318-213962348040]
	org.netbeans.modules.vmd.components.midp/2 [1.8 100318-213962348040]
	org.netbeans.modules.web.jsf12/1 [1.7.0.12 12 100318-213962348040]
	org.netbeans.modules.web.jsf12ri/1 [1.7.0.12 12 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.savaje [1.7 100318-213962348040]
	org.netbeans.modules.web.jsf20/1 [1.4.0.1 1 100318-213962348040]
	org.netbeans.modules.web.jsf/1 [1.18.0.2.43.2 2 100318-213962348040]
	org.netbeans.modules.mobility.deployment.ricoh [1.7 100318-213962348040]
	org.netbeans.modules.mobility.j2meunit [1.9 100318-213962348040]
	org.netbeans.modules.vmd.midp.converter [1.7 100318-213962348040]
	org.netbeans.modules.web.jsf.navigation/1 [2.8 100318-213962348040]
	org.netbeans.modules.web.jsf.editor [1.6 100318-213962348040]
	org.netbeans.modules.web.jsf.kit [1.7 100318-213962348040]
	org.netbeans.modules.mobility.databindingme/2 [1.8 100318-213962348040]
	org.netbeans.modules.mobility.end2end [1.8 100318-213962348040]
	org.netbeans.modules.mobility.jsr172 [1.8 100318-213962348040]
	org.netbeans.modules.websvc.rest.samples/0 [1.5 100318-213962348040]
	org.netbeans.modules.websvc.restlib/0 [1.6 100318-213962348040]
	org.netbeans.modules.websvc.saas.codegen.j2ee [1.6 100318-213962348040]
	org.netbeans.modules.apisupport.restsample [1.0 100318-213962348040]
	org.netbeans.modules.websvc.rest/0 [1.5 100318-213962348040]
	org.netbeans.modules.websvc.restkit/0 [1.5 100318-213962348040]
	org.netbeans.modules.identity.samples/1 [1.9 100318-213962348040]
	org.netbeans.modules.j2ee.ejbjarproject [1.21 100318-213962348040]
	org.netbeans.modules.j2ee.clientproject [1.15.0.1 1 100318-213962348040]
	org.netbeans.modules.j2ee.earproject [1.18 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.ricoh [1.7 100318-213962348040]
	org.netbeans.modules.mobility.proguard [1.11 100318-213962348040]
	org.netbeans.modules.j2ee.archive [1.8 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.nsicom [2.7 100318-213962348040]
	org.netbeans.modules.identity.ant/1 [1.7 100318-213962348040]
	org.netbeans.modules.vmd.components.midp.wma/2 [1.8 100318-213962348040]
	org.netbeans.modules.mobility.project.bridge.impl [1.6 100318-213962348040]
	org.netbeans.modules.mobility.deployment.sonyericsson [1.8 100318-213962348040]
	org.netbeans.libs.ppawtlayout/1 [1.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.sjmc [1.5 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.execuiimpl [1.5 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.nsicom [2.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.platform.nokias80 [1.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.project.nokiaS80 [1.7 100318-213962348040]
	org.netbeans.modules.j2me.cdc.kit [1.7 100318-213962348040]
	org.netbeans.modules.mobility.deployment.webdav [1.8 100318-213962348040]
	org.netbeans.modules.vmd.structure [1.7 100318-213962348040]
	org.netbeans.modules.vmd.components.midp.pda/2 [1.8 100318-213962348040]
	org.netbeans.modules.vmd.componentssupport [1.7 100318-213962348040]
	org.netbeans.modules.vmd.game [1.7 100318-213962348040]
	org.netbeans.modules.vmd.kit [1.8 100318-213962348040]
	org.netbeans.modules.mobility.plugins.mpowerplayer [1.6 100318-213962348040]
	org.netbeans.modules.deployment.wm [1.10 100318-213962348040]
	org.netbeans.modules.mobility.javahelp [1.9 100318-213962348040]
	org.netbeans.modules.mobility.kit [1.7 100318-213962348040]
	org.netbeans.modules.maven.j2ee/1 [1.6 100318-213962348040]
	org.netbeans.modules.mobility.end2end.kit [1.7 100318-213962348040]
	org.netbeans.modules.deployment.deviceanywhere [1.7 100318-213962348040]
	org.netbeans.modules.j2ee.ejbrefactoring [1.7 100318-213962348040]
	org.netbeans.modules.j2ee.platform/1 [1.13 100318-213962348040]
	org.netbeans.modules.j2ee.ejbverification [1.8 100318-213962348040]
	org.netbeans.modules.j2ee.kit [1.7 100318-213962348040]
	org.netbeans.modules.projectimport.eclipse.web [1.6.0.1 100318-213962348040]
	org.netbeans.modules.spring.webmvc [1.8 100318-213962348040]
	org.netbeans.modules.maven.jaxws [1.5 100318-213962348040]
	org.netbeans.modules.identity.kit [1.7 100318-213962348040]
Comment 1 _ tboudreau 2010-03-26 19:58:41 UTC
Created attachment 96014 [details]
Thread dump

After this, I went to Tools > Plugins and deactivated Ruby, PHP, Web & Java EE, and PHP.  Did not accept the restart option.  Finished editing the Java Class template and manually restarted.

On restart, the IDE hangs with edited files in the Loading... state and a progress bar in the progress area which says "Activating Java SE" (which I did not deactivate).  A number of threads are in Task.waitFinished() inside FolderInstance.
Comment 2 Jaroslav Tulach 2010-04-15 11:50:41 UTC
I reported the deadlock as bug 184229. I also reproduced the enabling problem.
Comment 3 Jaroslav Tulach 2010-04-15 11:58:37 UTC
This is problem between Java SE and Java ME. There is a following check in the JavaDataLoader:

        // ignore templates using scripting
        if (fo.getAttribute("template") != null && fo.getAttribute("javax.script.ScriptEngine") != null) // NOI18N
            return null;

as a result the valid Class.java template is not recognized as Java and instead it is being captured by the fake JavaME loader provided by ergonomics.

The simplest fix would be to change JavaDataLoader to return something for its templates (not necessarily JavaDataObject).
Comment 4 Jan Lahoda 2010-04-15 12:41:30 UTC
As this is now a defect filled against java.source, please define exactly what is the defect in java.source. Seems more like a defect in ergonomics (that it recognizes the file as belonging to J2ME), and/or in templates (that it does not have its own DO for freemarker-based templates, which it should, IMO). The proposed "solution" seems like a hack to me, inferior to any correct solution. If you want us to workaround something on java.source level, please provide rationale why the correct fixes are unfeasible. Thanks.
Comment 5 Jaroslav Tulach 2010-04-15 15:43:28 UTC
The base conflict is that the mime type of the file is text/x-java and existing support for Java refuses to deal with the file. This creates the whole confusion.

Why JavaDataObject is not created for the file? Because it is known to not be java? Well, then it shall not be recognized as text/x-java. Rather it should be text/x-freemarker. I can probably recognize all files with freemarker scripting engine as text/x-freemarker. Is this what you want?
Comment 6 Jan Lahoda 2010-04-15 18:55:58 UTC
(In reply to comment #5)
> The base conflict is that the mime type of the file is text/x-java and existing
> support for Java refuses to deal with the file. This creates the whole
> confusion.
> 
> Why JavaDataObject is not created for the file? Because it is known to not be
> java? Well, then it shall not be recognized as text/x-java. Rather it should be
> text/x-freemarker. I can probably recognize all files with freemarker scripting
> engine as text/x-freemarker. Is this what you want?

That may be appropriate, assuming it can be done without slowing-down the IDE (esp. scanning). Alternatively, the mentioned fake loader in ergonomics could be made to understand this. I was also thinking about the proposed simple solution in java.source, and I do not think it is simple. I see three possibilities:
-return JavaDataObject - but when the template is opened, it gets the Java syntax highlighting, which is not very appropriate and different from what we did in previous releases (ideally, IMO, the coloring should be three-fold: "top-level" language that would split freemarker from the content language, coloring for freemarker and coloring for the content language, in this case Java - contrib/freemarker shows what I mean. It currently uses FileUtil.getMIMEType of the given file to get the mime type of the content language, which would of course stop to work if the templates would be recognized as x-freemarker).
-return JDO and make it understand the file is actually not Java - possible, but cumbersome.
-return a brand new type of DataObjects, which would practically IMO mean java.source (and all other language supports) would need to have a copy of DefaultDataObject.

Is there some other possibility? Changing the fake loader in ergonomics is probably 3-5 line change, so I would consider it to be much simpler than the proposed simple change. Do I miss something?
Comment 7 Jaroslav Tulach 2010-04-16 06:02:57 UTC
I don't like the fact that knowledge of java/freemarker contract would be spread to ergonomics. But you are right, it is simple change. I'll keep thinking about the mimetype change (based on presence of "template" and "javax.script.ScriptEngine" attributes to be fast) and this one.
Comment 8 Jaroslav Tulach 2010-05-06 10:54:31 UTC
*** Bug 185545 has been marked as a duplicate of this bug. ***
Comment 9 Jaroslav Tulach 2010-05-24 07:53:45 UTC
core-main#8db612206a4e
Comment 10 Quality Engineering 2010-05-25 07:31:54 UTC
Integrated into 'main-golden', will be available in build *201005250001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8db612206a4e
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #182960: Recognize FreeMarker templates as text/x-freemarker
Comment 11 Jaroslav Tulach 2011-10-08 19:59:01 UTC
I am not sure this really works. I still see occational activation of Java ME in 7.0.1 and dev build of 7.1. Anyway the proper fix is not to disable java (coloring), but also enable the freemarker one.

We have unique opportunity to do that in 7.1 in a compatible way. Everyone had to rewrite their code to use multiview, often MultiDataObject.registerEditor and we can fix registerEditor to treat templates in right way.
Comment 12 Jaroslav Tulach 2011-10-08 20:07:56 UTC
Created attachment 111712 [details]
java.source, openide.loaders and libs.freemarker

This patch allows JavaDataLoader to recognize templates, creates new API contract in MultiDataObject.registerEditor that honors the javax.script.ScriptEngine property and makes sure, freemarker provides good enough mime type.
Comment 13 Jaroslav Tulach 2011-10-08 20:15:17 UTC
The contrib/freemarker template can delete its loader registration after applying the previous patch. I did it and JavaDataObject properly takes care of the templates, but the 

    public static EditorKit getEditorKit(String mimePath) {
        Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimePath));
        EditorKit kit = lookup.lookup(EditorKit.class);
        
        if (kit == null) {

in CloneableEditorSupport returns null for the Freemarker mime type. I don't know why and I am about to board. Lahváči, please look at it. If we could solve this last problem in general way, I believe we'd improved overall experience with templates for everyone.
Comment 14 Jaroslav Tulach 2011-11-08 08:32:32 UTC
OK, I'll integrate.
Comment 15 Jaroslav Tulach 2011-11-08 08:55:41 UTC
ergonomics#4db90535d1c0
Comment 16 Quality Engineering 2011-11-09 16:09:32 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/ddd3a0b02a16
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #182960: Freemarker declares that it supports text/x-freemarker mime type


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo