Bug 527131 - Tons of exceptions logged to OS console when switching EE to JavaSE-1.8
Summary: Tons of exceptions logged to OS console when switching EE to JavaSE-1.8
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-10 11:30 EST by Dani Megert CLA
Modified: 2023-11-30 10:32 EST (History)
2 users (show)

See Also:


Attachments
Exceptions in console (130.49 KB, text/plain)
2017-11-10 11:31 EST, Dani Megert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2017-11-10 11:30:01 EST
4.8 M3a

Tons of exceptions logged to console when switching EE to JavaSE-1.8.

In total I get 1365 lines spit into the OS console.

I'm marking this as critical since I have no clue what the impact is. Also, nothing in put into the .log.

Test Case:
1. Start new workspace with Java 9 (make sure you have an OS log console)
2. Create Java project 'P'
3. Add a Java 1.8 JRE
4. Switch the BREE for 'P' to 'JavaSE-1.8'
==> tons of exceptions logged to OS console. See attached file.
Comment 1 Dani Megert CLA 2017-11-10 11:31:00 EST
Created attachment 271412 [details]
Exceptions in console
Comment 2 Jay Arthanareeswaran CLA 2017-11-10 12:12:49 EST
I think this is expected. When there's a classpath change, we try to generate the delta and in the process try to resolve the package fragment roots. But now they are not part of project's build path anymore.

Looks like we get one exception for each module.

BTW, I don't see the errors in the console (but I tried with the most recent I build).
Comment 3 Dani Megert CLA 2017-11-10 12:23:32 EST
(In reply to Jay Arthanareeswaran from comment #2)
> I think this is expected.

You can maybe explain it, but it is for sure not expected to end in the console.

 
> BTW, I don't see the errors in the console (but I tried with the most recent
> I build).

Yeah, I wanted to give a stable build. I also used the latest I-build (eclipse-SDK-I20171108-2000-win32-x86_64).
Comment 4 Jay Arthanareeswaran CLA 2017-11-10 13:26:21 EST
I don't know why I am not seeing it in the console, but I see why it happens. It's a print stack statement in PackageFragmentRoot.getModuleDescription() which should be removed.
Comment 5 Stephan Herrmann CLA 2017-11-10 16:45:13 EST
(In reply to Jay Arthanareeswaran from comment #2)
> I think this is expected. When there's a classpath change, we try to
> generate the delta and in the process try to resolve the package fragment
> roots. But now they are not part of project's build path anymore.

This is true, but in order to compute a precise delta we should perhaps ignore the underlying ELEMENT_NOT_ON_CLASSPATH. Otherwise we are going to report removal of all roots in the JRT even if the project had access only to a few roots/modules (see how computePackageFragmentRoots() applies filtering IFF defaultRootModules() returns non-null).

Or is it OK, to send removal delta for s.t. that was never present?


Also note that there's a second "e.printStackTrace()" in JrtPackageFragmentRoot.getModule()
Comment 6 Stephan Herrmann CLA 2017-11-10 17:00:29 EST
As the filtering in computePackageFragmentRoots() has a finger in this pie, I should add that I'm not 100% sure, the implementation of limit-modules and default roots (for the unnamed module) is done in the best possible way.

(See also bug 526688 for some UI aspects of this).


When I added this filtering right into computePackageFragmentRoots() I was attracted by the simplicity of effectively hiding all modules which should not be observable.

As mentioned in bug 526688 this requires additional efforts if you want to access a type from a "hidden" module, be it for open type, completion or the like. This can be done, but ...

... I never considered the following alternative: instead of excluding hidden modules from the resolved classpath, we could perhaps use (a new kind of) AccessRestriction to signal: this module exists (physically) but is not normally observable.

While similar to existing logic, attaching AccessRestrictions to a module would require additional implementation efforts across several layers of the architecture.

Before further investigating feasibility of this alternative, which approach do you think better represents the intended semantics?

(a) Effectively exclude not-observable modules from the project's classpath.

(b) Include all modules but attach access restrictions to those that are not part of the module graph.

Intuitively I'd say, access restrictions are more like a missing "exports" and using them to signal absence from the module graph might be misuse.

Thoughts?
Comment 7 Stephan Herrmann CLA 2017-11-10 17:12:30 EST
While the question in comment 6 is connected to this bug, unfortunately neither option seems to give us a free lunch in this bug: the following predicate from JEP 261 requires indeed to inspect the details of each module available via JRT:

"every ... module ... that exports at least one package, without qualification,  ..."

This can only be answered if we really have the IModuleDescription :(

I could only think of caching the computed list of module names inside the JrtPackageFragmentRoot. Yea, maybe that would also reduce some of the performance problems we still have ...

Would such cache require updating when limit-modules is changed on the classpath entry or when the current project goes from unnamed to named module (or vice versa)?
Or could we assume that all these modifications will trigger computing new package fragment roots anyway?
Comment 8 Dani Megert CLA 2017-11-12 10:43:24 EST
(In reply to Stephan Herrmann from comment #6)
> Before further investigating feasibility of this alternative, which approach
> do you think better represents the intended semantics?
> 
> (a) Effectively exclude not-observable modules from the project's classpath.
> 
> (b) Include all modules but attach access restrictions to those that are not
> part of the module graph.
> 
> Intuitively I'd say, access restrictions are more like a missing "exports"
> and using them to signal absence from the module graph might be misuse.
> 
> Thoughts?

I also think access restrictions aren't the right thing here.


Independent of the technical issues that are now raised, writing to the console should be stopped. If we think we need to raise an error it should go to the .log.
Comment 9 Jay Arthanareeswaran CLA 2017-11-13 00:51:00 EST
(In reply to Dani Megert from comment #8)
> (In reply to Stephan Herrmann from comment #6)
> Independent of the technical issues that are now raised, writing to the
> console should be stopped. If we think we need to raise an error it should
> go to the .log.

I have replaced the print statements with logs:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=c2dfc61096af6f99f12808c54d0848932a39943a

(In reply to Stephan Herrmann from comment #7)
> Would such cache require updating when limit-modules is changed on the
> classpath entry or when the current project goes from unnamed to named
> module (or vice versa)?
> Or could we assume that all these modifications will trigger computing new
> package fragment roots anyway?

I don't think so. This would require some work, I guess.
Comment 10 Stephan Herrmann CLA 2017-11-13 15:26:17 EST
(In reply to Jay Arthanareeswaran from comment #9)
> (In reply to Stephan Herrmann from comment #7)
> > Would such cache require updating when limit-modules is changed on the
> > classpath entry or when the current project goes from unnamed to named
> > module (or vice versa)?
> > Or could we assume that all these modifications will trigger computing new
> > package fragment roots anyway?
> 
> I don't think so.

To which part of the "or"?
Comment 11 Stephan Herrmann CLA 2019-12-17 16:01:46 EST
(In reply to Jay Arthanareeswaran from comment #9)
> (In reply to Stephan Herrmann from comment #7)
> > Would such cache require updating when limit-modules is changed on the
> > classpath entry or when the current project goes from unnamed to named
> > module (or vice versa)?
> > Or could we assume that all these modifications will trigger computing new
> > package fragment roots anyway?
> 
> I don't think so. This would require some work, I guess.

This could deserve new assessment after bug 466299 got resolved, which includes processing deltas regarding extra attributes (like limit-modules and friends).

Anyway, caching would only possibly reduce the number of log entries, not avoid them completely.
Comment 12 Eclipse Genie CLA 2021-12-07 12:44:17 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 13 Eclipse Genie CLA 2023-11-30 10:32:55 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.