Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Access jdk.unsupported from JUnit doesn't need module require

  • Emrah KAYA
  • 2024-10-17
  • 11
Access jdk.unsupported from JUnit doesn't need module require
  • ok logo

Скачать Access jdk.unsupported from JUnit doesn't need module require бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Access jdk.unsupported from JUnit doesn't need module require или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Access jdk.unsupported from JUnit doesn't need module require бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Access jdk.unsupported from JUnit doesn't need module require

Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram:   / ky.emrah  

Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Access jdk.unsupported from JUnit doesn't need module require

I'm trying to figure out why JUnit behaves differently from a 'regular' Java program with respect to the jdk.unsupported module. And yes, I know I shouldn't be using this. I'm just trying (and failing) to understand how things work.
jdk.unsupported
I have this program:
public class UnsafeAttempt {
public static void main(String[] args) {
try {
Class.forName("sun.reflect.ReflectionFactory");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}

public class UnsafeAttempt {
public static void main(String[] args) {
try {
Class.forName("sun.reflect.ReflectionFactory");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}

When run on the modulepath, this throws a java.lang.ClassNotFoundException, which I expect. When I add requires jdk.unsupported; to module-info.java, it runs without problems, which I also expect.
java.lang.ClassNotFoundException
requires jdk.unsupported;
module-info.java
But if I put it in a unit test:
import org.junit.jupiter.api.Test;

public class UnsafeTest {
@Test
public void sunreflect() throws Exception {
Class.forName("sun.reflect.ReflectionFactory");
}
}

import org.junit.jupiter.api.Test;

public class UnsafeTest {
@Test
public void sunreflect() throws Exception {
Class.forName("sun.reflect.ReflectionFactory");
}
}

With this module-info.java file in src/test/java:
module-info.java
src/test/java
open module my.module {
exports my.module;

requires org.junit.jupiter.api;
}

open module my.module {
exports my.module;

requires org.junit.jupiter.api;
}

This works without adding requires jdk.unsupported;, and I don't understand why.
without
requires jdk.unsupported;
I see this behaviour in both IntelliJ and Maven. I haven't configured the Maven Surefire plugin in any way.
What does JUnit or Surefure (or something else) do to make this work?
EDIT: I've created a GitHub repo with a reproducer, to make it easier to try this: https://github.com/jqno/modules-are-c...
EDIT
https://github.com/jqno/modules-are-c...


Tags: java,junit5,java-platform-module-systemSource of the question:
https://stackoverflow.com/questions/7...

Question and source license information:
https://meta.stackexchange.com/help/l...
https://stackoverflow.com/

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]