Skip to content

refactor: remove the package existing in java8#2792

Merged
imbajin merged 2 commits intoapache:masterfrom
Tsukilc:remove-jdk8-reflect
Sep 28, 2025
Merged

refactor: remove the package existing in java8#2792
imbajin merged 2 commits intoapache:masterfrom
Tsukilc:remove-jdk8-reflect

Conversation

@Tsukilc
Copy link
Collaborator

@Tsukilc Tsukilc commented Jun 10, 2025

Purpose of the PR

sub task of [#2724](#2764)
No longer maintain compatibility with java8 and delete the sun.reflection-related reflection packages of java8

Main Changes

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 10, 2025
@Tsukilc Tsukilc changed the title refactor(version): Delete the package existing in java8 refactor: Delete the package existing in java8 Jun 10, 2025
@github-actions
Copy link

Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes Java 8 compatibility by eliminating sun.reflect-related reflection packages and hardcoding the use of jdk.internal.reflect.Reflection for Java 11+.

  • Removes fallback support for Java 8's sun.reflect.Reflection package
  • Updates error messages to explicitly require Java 11 or higher
  • Cleans up conditional class loading logic that previously supported both Java 8 and 11+ reflection APIs

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Reflection.java Simplifies reflection class loading by removing Java 8 fallback and hardcoding jdk.internal.reflect.Reflection
HugeSecurityManager.java Removes sun.reflect.DelegatingClassLoader from accepted class loaders list
HugeFactoryAuthProxy.java Removes Java 8-specific reflection filter registrations and updates logging

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 42 to 55

registerFieldsToFilterMethodTemp =
reflectionClazzTemp.getMethod("registerFieldsToFilter",
Class.class, String[].class);

registerMethodsToFilterMethodTemp =
reflectionClazzTemp.getMethod("registerMethodsToFilter",
Class.class, String[].class);
} catch (ClassNotFoundException e) {
try {
reflectionClazzTemp = Class.forName(SUN_REFLECT_REFLECTION);
} catch (ClassNotFoundException ex) {
LOG.error("Can't find Reflection class", ex);
}
LOG.error("Can't find jdk.internal.reflect.Reflection class, " +
"please ensure you are using Java 11", e);
} catch (NoSuchMethodException e) {
LOG.error("Can't find reflection filter methods", e);
}
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method lookup logic should be wrapped in a try-catch block to handle NoSuchMethodException separately from ClassNotFoundException, ensuring proper error handling for each failure scenario.

Copilot uses AI. Check for mistakes.
Comment on lines +637 to +638
LOG.debug("Internal class {} not found in this JDK implementation, skipping filter registration",
className, e);
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message has a grammatical error. 'Internal class {} not found in this JDK implementation' should be 'Internal class {} not found in this JDK implementation,'.

Copilot uses AI. Check for mistakes.
@Tsukilc Tsukilc force-pushed the remove-jdk8-reflect branch from 26da84d to 8ccff76 Compare September 14, 2025 06:41
imbajin
imbajin previously approved these changes Sep 14, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 14, 2025
Comment on lines +636 to +639
LOG.debug(
"Internal class {} not found in this JDK implementation, skipping filter " +
"registration",
className, e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

@imbajin imbajin requested a review from VGalaxies September 14, 2025 16:12
@codecov
Copy link

codecov bot commented Sep 14, 2025

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.08%. Comparing base (0946d5d) to head (018738d).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...ain/java/org/apache/hugegraph/util/Reflection.java 0.00% 10 Missing ⚠️
...rg/apache/hugegraph/auth/HugeFactoryAuthProxy.java 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0946d5d) and HEAD (018738d). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (0946d5d) HEAD (018738d)
3 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #2792       +/-   ##
============================================
- Coverage     40.91%   0.08%   -40.83%     
+ Complexity      333      22      -311     
============================================
  Files           747     725       -22     
  Lines         60168   57643     -2525     
  Branches       7683    7234      -449     
============================================
- Hits          24615      51    -24564     
- Misses        32975   57590    +24615     
+ Partials       2578       2     -2576     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

private static final Method REGISTER_METHODS_TO_FILTER_METHOD;

public static final String JDK_INTERNAL_REFLECT_REFLECTION = "jdk.internal.reflect.Reflection";
public static final String SUN_REFLECT_REFLECTION = "sun.reflect.Reflection";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this constant variables?

@imbajin imbajin changed the title refactor: Delete the package existing in java8 refactor: remove the package existing in java8 Sep 28, 2025
@imbajin imbajin merged commit da6b123 into apache:master Sep 28, 2025
13 of 15 checks passed
imbajin pushed a commit to hugegraph/hugegraph that referenced this pull request Sep 30, 2025
* refactor: Delete the package existing in java8

* chore(format): remove custom line breaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inactive lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants