-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Agent should not open java.lang
package to unnamed module of the application class loader
#1334
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
77d7579
(WIP) add integration test
Godin 7d5e501
(WIP) agent should not open `java.lang` package to unnamed module of …
Godin caa7e44
(WIP) InjectedClassRuntime.createFor
Godin 6049ed3
(WIP) use custom ClassLoader only for Lookup class
Godin f03537a
Merge branch 'master' into issue-1328
Godin a19d011
Merge branch 'master' into issue-1328
Godin 22fab1e
Revert "(WIP) use custom ClassLoader only for Lookup class"
Godin 7b1b7e5
Merge branch 'master' into issue-1328
Godin 1a3c4dd
(WIP) add missing `@throws` javadoc
Godin 6b13f21
(WIP) add comments
Godin 4fae4b0
(WIP) simplify code
Godin bda0b69
(WIP) update changelog
Godin 9b4777b
Apply suggestions from code review
Godin 215a81a
Merge branch 'master' into issue-1328
Godin 316e5bc
(WIP) update copyright year
Godin 374c86b
Separate class loading from runtime
marchof 5cadc6c
Merge branch 'master' into issue-1328
Godin File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
org.jacoco.ant.test/src/org/jacoco/ant/IllegalReflectiveAccessTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2022 Mountainminds GmbH & Co. KG and Contributors | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
|
||
package org.jacoco.ant; | ||
|
||
import java.lang.reflect.Constructor; | ||
|
||
public class IllegalReflectiveAccessTarget { | ||
|
||
public static void main(String[] args) throws Exception { | ||
try { | ||
Class.forName("java.lang.invoke.MethodHandles$Lookup") | ||
.getField("ORIGINAL"); | ||
} catch (ClassNotFoundException e) { | ||
// Java < 7 | ||
return; | ||
} catch (NoSuchFieldException e) { | ||
// Java < 16 | ||
return; | ||
} | ||
Godin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
final Constructor<?> c = Class.forName("java.lang.Module") | ||
.getDeclaredConstructors()[0]; | ||
try { | ||
c.setAccessible(true); | ||
throw new AssertionError("Exception expected"); | ||
} catch (RuntimeException e) { | ||
if (!e.getClass().getName() | ||
.equals("java.lang.reflect.InaccessibleObjectException")) { | ||
throw new AssertionError( | ||
"InaccessibleObjectException expected"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To further encapsulate the implementation details of
InjectedClassRuntime
I would add a static methodisSupported()
to this class. The code here in PreMain then reduces to: