You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, Record, or PermittedSubclasses attribute
#744
Open
4 tasks done
mgorovoy opened this issue
Jun 30, 2023
· 0 comments
Description of the problem or enhancement request: Execution of a test that mocks specific class results in following exception - java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, Record, or PermittedSubclasses attribute
Check the following:
If a defect or unexpected result, JMockit project members should be able to reproduce it.
For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
can be executed without changes and reproduces the failure.
If an enhancement or new feature request, it should be justified by an example test
demonstrating the validity and usefulness of the desired enhancement or new feature.
The issue does not fall outside the scope of the project (for example, attempting to use
JMockit APIs from Groovy or Scala code, or with an Android runtime).
The JDK where the problem occurs is a final release, not a development build.
The issue #740 appears to describe the same situation, but lacks details or example to reproduce it.
I've stripped the class from our product that was being mocked until I found the minimum viable example of the test (attached) that causes it to fail. I've been able to reproduce the failure both with Maven 3.9.3 (see below), as well as Eclipse 2023-6 on macOS. I've tried both OpenJDK 17.0.2 on macOS and Oracle JDK 17.0.2 on Windows with the same results.
The issue seems to occur because the first element in static enum declaration overrides a method of the enum class as follows.
COUNT {
@Override
public void send(OutputStream outputStream) throws IOException {
// do something
}
},
Removing this override as follows makes the exception disappear.
COUNT,
Unfortunately, we use this type of construct in many places throughout our product, and the specific class that this example is borrowed from is mocked very extensively throughout our tests. jmockit-test.tar.gz
The text was updated successfully, but these errors were encountered:
Please provide the following information:
Version of JMockit that was used: 1.49
Version of JDK that was used: 17.0.2
Description of the problem or enhancement request: Execution of a test that mocks specific class results in following exception - java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, Record, or PermittedSubclasses attribute
Check the following:
If a defect or unexpected result, JMockit project members should be able to reproduce it.
For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
can be executed without changes and reproduces the failure.
If an enhancement or new feature request, it should be justified by an example test
demonstrating the validity and usefulness of the desired enhancement or new feature.
The issue does not fall outside the scope of the project (for example, attempting to use
JMockit APIs from Groovy or Scala code, or with an Android runtime).
The JDK where the problem occurs is a final release, not a development build.
The issue #740 appears to describe the same situation, but lacks details or example to reproduce it.
I've stripped the class from our product that was being mocked until I found the minimum viable example of the test (attached) that causes it to fail. I've been able to reproduce the failure both with Maven 3.9.3 (see below), as well as Eclipse 2023-6 on macOS. I've tried both OpenJDK 17.0.2 on macOS and Oracle JDK 17.0.2 on Windows with the same results.
$ mvn -v
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: /usr/local/Cellar/maven/3.9.3/libexec
Java version: 17.0.7, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.7/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "13.4.1", arch: "x86_64", family: "mac"
The issue seems to occur because the first element in static enum declaration overrides a method of the enum class as follows.
Removing this override as follows makes the exception disappear.
Unfortunately, we use this type of construct in many places throughout our product, and the specific class that this example is borrowed from is mocked very extensively throughout our tests.
jmockit-test.tar.gz
The text was updated successfully, but these errors were encountered: