Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with JAR in debug mode with m2e ("no java context") #86

Open
glhez opened this issue Jul 19, 2022 · 2 comments
Open

Issue with JAR in debug mode with m2e ("no java context") #86

glhez opened this issue Jul 19, 2022 · 2 comments

Comments

@glhez
Copy link

glhez commented Jul 19, 2022

Hello,

Since latest version of Eclipse (I'd say at least 2021-12), I am under the impression that Eclipse fails at inspecting the context of variable/evaluating/properly displaying the *.class I am stepping into.

This affects expressions and conditional breakpoints since the context is being used to compile conditional expressions: the debugger is practically useless without those.

The screenshot below provides 4 examples of problem with the debug mode, from which I fail to understand why it fails while it was not:

Screenshot Description
eclipse_no_debug_context_01 a Tomcat 8.5 Server launch and Spring 5 (no spring boot)
eclipse_no_debug_context_02 a JUnit 3 unit test with Spring 3 (sic)
eclipse_no_debug_context_03 a JUnit 4 unit test for issue HHH-15142; we can see the breadcumb and local variables being lost
eclipse_no_debug_context_04 same project as eclipse_no_debug_context_03.png; unlike before, the local variables are resolved;

In all these screenshot, we can see the breadcumb not displaying the enclosing type/file: this is strange because the editor title is properly set, and the window title also references the JAR from which the source file comes (but I don't know if it should read "junit-4.13.2-sources.jar" and not "junit-4.13.2.jar".

The first two screenshot were taken from a work related project which I can't attach here.

The last two screenshots were taken using the sample project from issue HHH-15142 (https://github.com/schauder/issue-HHH-15142 and spring-projects/spring-data-jpa#2472):

  • Clone the GIT repository
  • In Eclipse, go to File > Import > Import Maven project
  • Browse to where GIT repository was cloned
  • Go to type org.hibernate.query.spi.QueryParameterBindingValidator and put a breakpoint at line 53 where the "Parameter value [%s] did not match expected type [%s (%s)]" should be.
  • Put a breakpoint to org.hibernate.query.spi.QueryParameterBindingValidator line 53
  • Go to JPAUnitTestCase
  • Run it as JUnit 4 test (the default F11 will try to use JUnit Jupiter and find nothing)
  • Wait for Eclipse to switch/ask to use Debug perspective
  • Navigate the stack trace

The table below shows when it fails: some JAR are from Maven, while other are from Eclipse bundle.

breadcumb local variables source Type / Method / Line
Ok Ok JAR: Hibernate QueryParameterBindingValidator.validate(Type, Object, TemporalType) line: 53
Ok Ok JAR: Hibernate QueryParameterBindingValidator.validate(Type, Object) line: 27
Ok Ok JAR: Hibernate QueryParameterBindingImpl<T>.validate(T) line: 90
Ok Ok JAR: Hibernate QueryParameterBindingImpl<T>.setBindValue(T) line: 55
Ok Ok JAR: Hibernate QueryImpl<R>(AbstractProducedQuery<R>).setParameter(String, Object) line: 501
Ok Ok JAR: Hibernate QueryImpl<R>(AbstractProducedQuery<R>).setParameter(String, Object) line: 122
Ok Ok JAR: Hibernate CriteriaCompiler$1$1.bind(TypedQuery) line: 141
Ok Ok JAR: Hibernate CriteriaQueryImpl$1.buildCompiledQuery(SharedSessionContractImplementor, InterpretedParameterMetadata) line: 364
Ok Ok JAR: Hibernate CriteriaCompiler.compile(CompilableCriteria) line: 171
Ok Ok JAR: Hibernate SessionImpl(AbstractSharedSessionContract).createQuery(CriteriaQuery<T>) line: 774
Ok Ok JAR: Hibernate SessionImpl(AbstractSessionImpl).createQuery(CriteriaQuery) line: 23
Ok Ok Project JPAUnitTestCase.hhh123Test() line: 65
Ok Ok JDK NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
Ok Ok JDK NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
Ok Ok JDK DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Ok Ok JDK Method.invoke(Object, Object...) line: 498
Fail Fail JAR: JUnit FrameworkMethod$1.runReflectiveCall() line: 59
Fail (none) JAR: JUnit FrameworkMethod$1(ReflectiveCallable).run() line: 12
Fail Ok JAR: JUnit FrameworkMethod.invokeExplosively(Object, Object...) line: 56
Fail (none) JAR: JUnit InvokeMethod.evaluate() line: 17
Fail (none) JAR: JUnit RunBefores.evaluate() line: 26
Fail Ok JAR: JUnit RunAfters.evaluate() line: 27
Fail Fail JAR: JUnit ParentRunner$3.evaluate() line: 306
Fail Fail JAR: JUnit BlockJUnit4ClassRunner$1.evaluate() line: 100
Fail Ok JAR: JUnit JUnit4(ParentRunner<T>).runLeaf(Statement, Description, RunNotifier) line: 366
Fail Ok JAR: JUnit JUnit4(BlockJUnit4ClassRunner).runChild(FrameworkMethod, RunNotifier) line: 103
Fail Ok JAR: JUnit JUnit4(BlockJUnit4ClassRunner).runChild(Object, RunNotifier) line: 63
Fail Fail JAR: JUnit ParentRunner$4.run() line: 331
Fail Ok JAR: JUnit ParentRunner$1.schedule(Runnable) line: 79
Fail Ok JAR: JUnit JUnit4(ParentRunner<T>).runChildren(RunNotifier) line: 329
Fail Ok JAR: JUnit ParentRunner<T>.access$100(ParentRunner, RunNotifier) line: 66
Fail Fail JAR: JUnit ParentRunner$2.evaluate() line: 293
Fail Fail JAR: JUnit ParentRunner$3.evaluate() line: 306
Fail Ok JAR: JUnit JUnit4(ParentRunner<T>).run(RunNotifier) line: 413
No source No source Eclipse Bundle JUnit4TestReference.run(TestExecution) line: 93
No source No source Eclipse Bundle TestExecution.run(ITestReference[]) line: 40
No source No source Eclipse Bundle RemoteTestRunner.runTests(String[], String, TestExecution) line: 529
No source No source Eclipse Bundle RemoteTestRunner.runTests(TestExecution) line: 756
No source No source Eclipse Bundle RemoteTestRunner.run() line: 452
No source No source Eclipse Bundle RemoteTestRunner.main(String[]) line: 210

When I right click on a method in the stacktrace, I do have the "Source lookup info" (which to my understanding of plugin.xml comes from m2e-core, and especially this class: https://github.com/eclipse-m2e/m2e-core/blob/4e7ba8113e8cff1d84a05918addd8c27a108d591/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/OpenSourceLookupInfoDialogCommandHandler.java )

The information it returns shows there are 3 kind of source containers:

Location: E:\apps\data\maven\local\org\hibernate\hibernate-core\5.6.6.Final\hibernate-core-5.6.6.Final.jar
GAV: [org.hibernate:hibernate-core:5.6.6.Final]
Java project: <not-implemented>
Source container: PackageFragmentRootSourceContainer hibernate-core-5.6.6.Final.jar P/test-case-template-hibernate-orm5

Location: E:\git\external\github\issue-HHH-15142\target\test-classes
GAV: []
Java project: <not-implemented>
Source container: JavaProjectSourceContainer test-case-template-hibernate-orm5

Location: E:\apps\data\maven\local\junit\junit\4.13.2\junit-4.13.2.jar
GAV: [junit:junit:4.13.2]
Java project: <not-implemented>
Source container: ExternalArchiveSourceContainer E:\apps\data\maven\local\junit\junit\4.13.2\junit-4.13.2-sources.jar

I don't understand the rational that explain why the first one is a PackageFragmentRootSourceContainer, which works, and the last fails (ExternalArchiveSourceContainer), but I find it strange for it to reference the sources.jar rather than the jar itself.

The ExternalArchiveSourceContainer is used when importing project as Maven and as "simple" Java project :

  • I transformed the reproducer project of https://github.com/schauder/issue-HHH-15142 into a "simple Java project" (eg: not a "Import as Maven project") : it is present here, but without its JAR dependencies (= 44M)
  • Clone the referenced project: git clone https://github.com/glhez/issue-HHH-15142.git
  • In a terminal, go the directory and execute maven:
./mvnw dependency:copy-dependencies -Dclassifier=sources -DoutputDirectory=lib/sources
./mvnw dependency:copy-dependencies -DoutputDirectory=lib/binaries
  • Once done, the project and its launch (JPAUnitTestCase.launch) can be imported in Eclipse using "Import Java Project" (not "Maven Project").

We can see the same problem, perhaps not at the same location since I can browse Hibernate finely : this happens in the JUNIT 4 part:

no_context_in_junit4

There are

  1. no debug information in expressions, which is another (frustrating) problem I have with Eclipse, since it should know the project from which a launch comes
  2. no information while hovering the junit 4 class

I did not try conditional breakpoint, but I think they would fail because "There a no java context".

Versions:

Java 17 + Eclipse 2022-03 Eclipse 2022-06
M2E - Maven Integration for Eclipse (includes Incubating components) 1.20.1.20220227-1319 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e
M2E - POM Editor using LemMinX language server (includes Incubating components) 1.18.4.20220127-1634 org.eclipse.m2e.lemminx.feature.feature.group Eclipse.org - m2e
M2E - SLF4J over Logback Logging (optional) 1.17.2.20211002-1029 org.eclipse.m2e.logback.feature.feature.group Eclipse.org - m2e

The Eclipse installation has been installed using Oomph and Eclipse 2022-06 as its base.

Note: I originally created the bug here https://bugs.eclipse.org/bugs/show_bug.cgi?id=579535 without much updates on it.

@stephendnicholas
Copy link

I've raised a discussion thread which I think could be related: #406

@glhez
Copy link
Author

glhez commented Mar 12, 2024

I sincerely hope there will be some discussion around that because that make the debug experience pretty frustrating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants