Skip to content

Commit

Permalink
Don't use deprecated SecurityManager, use StackWalker instead
Browse files Browse the repository at this point in the history
Have to fix this warning to fix compilation error in Jenkins

See #493
  • Loading branch information
iloveeclipse committed Mar 23, 2023
1 parent e5f0909 commit 7346bda
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor;

import java.lang.StackWalker.StackFrame;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.CharacterIterator;
Expand All @@ -27,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Predicate;

import com.ibm.icu.text.BreakIterator;

Expand Down Expand Up @@ -4249,19 +4251,17 @@ public JavaPairMatcher getBracketMatcher() {
* @since 3.9
*/
private static boolean isCalledByOutline() {
Class<?>[] elements= new AccessChecker().getClassContext();
for (int i= 0; i < elements.length && i < 10; i++) {
if (elements[i].equals(ContentOutline.class)) {
return true;
}
}
return false;
return OutlineAccessChecker.isCalledByOutline();
}

private static final class AccessChecker extends SecurityManager {
@Override
public Class<?>[] getClassContext() {
return super.getClassContext();
private static final class OutlineAccessChecker {
private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
private static final String OUTLINE_NAME = ContentOutline.class.getCanonicalName();
private static final Predicate<? super StackFrame> CHECK_OUTLINE = frame -> OUTLINE_NAME.equals(frame.getClassName());

static boolean isCalledByOutline() {
Boolean wasCalled = STACK_WALKER.walk(fs -> Boolean.valueOf(fs.anyMatch(CHECK_OUTLINE)));
return wasCalled.booleanValue();
}
}

Expand Down

0 comments on commit 7346bda

Please sign in to comment.