mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
correctly fixed not-null instrumentation for enums (IDEA-56943)
This commit is contained in:
+3
-3
@@ -122,8 +122,8 @@ public class NotNullVerifyingInstrumenter extends ClassAdapter implements Opcode
|
||||
}
|
||||
for (int p = 0; p < myNotNullParams.size(); ++p) {
|
||||
int var = ((access & ACC_STATIC) == 0) ? 1 : 0;
|
||||
int param = ((Integer)myNotNullParams.get(p)).intValue() - mySyntheticCount;
|
||||
for (int i = 0; i < param + startParameter; ++i) {
|
||||
int param = ((Integer)myNotNullParams.get(p)).intValue();
|
||||
for (int i = 0; i < startParameter + param; ++i) {
|
||||
var += args[i].getSize();
|
||||
}
|
||||
mv.visitVarInsn(ALOAD, var);
|
||||
@@ -132,7 +132,7 @@ public class NotNullVerifyingInstrumenter extends ClassAdapter implements Opcode
|
||||
mv.visitJumpInsn(IFNONNULL, end);
|
||||
|
||||
generateThrow(IAE_CLASS_NAME,
|
||||
"Argument " + param + " for @NotNull parameter of " + myClassName + "." + name + " must not be null", end);
|
||||
"Argument " + (param - mySyntheticCount) + " for @NotNull parameter of " + myClassName + "." + name + " must not be null", end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum EnumConstructorSecondParam {
|
||||
Value("1", "2");
|
||||
|
||||
EnumConstructorSecondParam(String s1, @NotNull String s2) {
|
||||
}
|
||||
}
|
||||
+6
@@ -63,6 +63,12 @@ public class NotNullVerifyingInstrumenterTest extends UsefulTestCase {
|
||||
assertNotNull(field);
|
||||
}
|
||||
|
||||
public void testEnumConstructorSecondParam() throws Exception {
|
||||
Class testClass = prepareTest();
|
||||
Object field = testClass.getField("Value");
|
||||
assertNotNull(field);
|
||||
}
|
||||
|
||||
private static void verifyCallThrowsException(final String expectedError, final Object instance, final Method method, final Object... args) throws IllegalAccessException {
|
||||
String exceptionText = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user