Lines 2782-2787
Link Here
|
2782 |
removeTempClass("A62"); |
2782 |
removeTempClass("A62"); |
2783 |
} |
2783 |
} |
2784 |
} |
2784 |
} |
|
|
2785 |
public void test065() { |
2786 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) return; |
2787 |
try { |
2788 |
String sourceA65 = |
2789 |
"public class A65<T> {\n" |
2790 |
+ "\tprivate int i;\n" |
2791 |
+ "\tpublic <U>A65() {;\n" |
2792 |
+ "\t}\n" |
2793 |
+ "\tprivate <U>A65(int i) {;\n" |
2794 |
+ "\t\tthis.i = i;\n" |
2795 |
+ "\t}\n" |
2796 |
+ "\tpublic void bar() {\n" |
2797 |
+ "\t}\n" |
2798 |
+ "}"; |
2799 |
compileAndDeploy15(sourceA65, "A65"); |
2800 |
|
2801 |
String userCode = "new <Object>A65<Object>().bar();"; |
2802 |
JDIStackFrame stackFrame = |
2803 |
new JDIStackFrame(this.jdiVM, this, userCode, "A65", "bar", -1); |
2804 |
|
2805 |
DebugRequestor requestor = new DebugRequestor(); |
2806 |
char[] snippet = "return new <Object>A65<Object>(3).i;".toCharArray(); |
2807 |
try { |
2808 |
this.context.evaluate( |
2809 |
snippet, |
2810 |
stackFrame.localVariableTypeNames(), |
2811 |
stackFrame.localVariableNames(), |
2812 |
stackFrame.localVariableModifiers(), |
2813 |
stackFrame.declaringTypeName(), |
2814 |
stackFrame.isStatic(), |
2815 |
stackFrame.isConstructorCall(), |
2816 |
getEnv(), |
2817 |
getCompilerOptions(), |
2818 |
requestor, |
2819 |
getProblemFactory()); |
2820 |
} catch (InstallException e) { |
2821 |
assertTrue("No targetException " + e.getMessage(), false); |
2822 |
} |
2823 |
assertTrue( |
2824 |
"Should get one result but got " + (requestor.resultIndex + 1), |
2825 |
requestor.resultIndex == 0); |
2826 |
EvaluationResult result = requestor.results[0]; |
2827 |
assertTrue("Code snippet should not have problems", !result.hasProblems()); |
2828 |
assertTrue("Result should have a value", result.hasValue()); |
2829 |
assertEquals("Value", "3".toCharArray(), result.getValueDisplayString()); |
2830 |
assertEquals("Type", "int".toCharArray(), result.getValueTypeName()); |
2831 |
} finally { |
2832 |
removeTempClass("A65"); |
2833 |
} |
2834 |
} |
2835 |
public void test066() { |
2836 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) return; |
2837 |
try { |
2838 |
String sourceA66 = |
2839 |
"public class A66 {\n" |
2840 |
+ "\tprivate int i;\n" |
2841 |
+ "\tpublic A66() {;\n" |
2842 |
+ "\t}\n" |
2843 |
+ "\tprivate <U> int foo(int i) {;\n" |
2844 |
+ "\t\treturn i;\n" |
2845 |
+ "\t}\n" |
2846 |
+ "\tpublic void bar() {\n" |
2847 |
+ "\t}\n" |
2848 |
+ "}"; |
2849 |
compileAndDeploy15(sourceA66, "A66"); |
2850 |
|
2851 |
String userCode = "new A66().bar();"; |
2852 |
JDIStackFrame stackFrame = |
2853 |
new JDIStackFrame(this.jdiVM, this, userCode, "A66", "bar", -1); |
2854 |
|
2855 |
DebugRequestor requestor = new DebugRequestor(); |
2856 |
char[] snippet = "return this.<Object>foo(3);".toCharArray(); |
2857 |
try { |
2858 |
this.context.evaluate( |
2859 |
snippet, |
2860 |
stackFrame.localVariableTypeNames(), |
2861 |
stackFrame.localVariableNames(), |
2862 |
stackFrame.localVariableModifiers(), |
2863 |
stackFrame.declaringTypeName(), |
2864 |
stackFrame.isStatic(), |
2865 |
stackFrame.isConstructorCall(), |
2866 |
getEnv(), |
2867 |
getCompilerOptions(), |
2868 |
requestor, |
2869 |
getProblemFactory()); |
2870 |
} catch (InstallException e) { |
2871 |
assertTrue("No targetException " + e.getMessage(), false); |
2872 |
} |
2873 |
assertTrue( |
2874 |
"Should get one result but got " + (requestor.resultIndex + 1), |
2875 |
requestor.resultIndex == 0); |
2876 |
EvaluationResult result = requestor.results[0]; |
2877 |
assertTrue("Code snippet should not have problems", !result.hasProblems()); |
2878 |
assertTrue("Result should have a value", result.hasValue()); |
2879 |
assertEquals("Value", "3".toCharArray(), result.getValueDisplayString()); |
2880 |
assertEquals("Type", "int".toCharArray(), result.getValueTypeName()); |
2881 |
} finally { |
2882 |
removeTempClass("A66"); |
2883 |
} |
2884 |
} |
2885 |
public void test067() { |
2886 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) return; |
2887 |
try { |
2888 |
String sourceA67 = |
2889 |
"import java.util.List;\n" + |
2890 |
"public class A67<T> {\n" + |
2891 |
" public static String toString(List<?> list) {\n" + |
2892 |
" StringBuilder builder = new StringBuilder(\"{\");\n" + |
2893 |
" for (Object o : list) {" + |
2894 |
" builder.append(o);\n" + |
2895 |
" }\n" + |
2896 |
" builder.append(\"}\");\n" + |
2897 |
" return String.valueOf(builder);\n" + |
2898 |
" }\n" + |
2899 |
" public void bar() {\n" + |
2900 |
" }\n" + |
2901 |
"}"; |
2902 |
compileAndDeploy15(sourceA67, "A67"); |
2903 |
|
2904 |
String userCode = "new A67<Object>().bar();"; |
2905 |
JDIStackFrame stackFrame = |
2906 |
new JDIStackFrame(this.jdiVM, this, userCode, "A67", "bar", -1); |
2907 |
|
2908 |
DebugRequestor requestor = new DebugRequestor(); |
2909 |
char[] snippet = ("java.util.ArrayList<String> list = new java.util.ArrayList<String>();\n" + |
2910 |
"list.add(\"Test\");\n" + |
2911 |
"list.add(\"Hello\");\n" + |
2912 |
"list.add(\"World\");\n" + |
2913 |
"return A67.toString(list);").toCharArray(); |
2914 |
try { |
2915 |
this.context.evaluate( |
2916 |
snippet, |
2917 |
stackFrame.localVariableTypeNames(), |
2918 |
stackFrame.localVariableNames(), |
2919 |
stackFrame.localVariableModifiers(), |
2920 |
stackFrame.declaringTypeName(), |
2921 |
stackFrame.isStatic(), |
2922 |
stackFrame.isConstructorCall(), |
2923 |
getEnv(), |
2924 |
getCompilerOptions(), |
2925 |
requestor, |
2926 |
getProblemFactory()); |
2927 |
} catch (InstallException e) { |
2928 |
assertTrue("No targetException " + e.getMessage(), false); |
2929 |
} |
2930 |
assertTrue( |
2931 |
"Should get one result but got " + (requestor.resultIndex + 1), |
2932 |
requestor.resultIndex == 0); |
2933 |
EvaluationResult result = requestor.results[0]; |
2934 |
assertTrue("Code snippet should not have problems", !result.hasProblems()); |
2935 |
assertTrue("Result should have a value", result.hasValue()); |
2936 |
assertEquals("Value", "{TestHelloWorld}".toCharArray(), result.getValueDisplayString()); |
2937 |
assertEquals("Type", "java.lang.String".toCharArray(), result.getValueTypeName()); |
2938 |
} finally { |
2939 |
removeTempClass("A67"); |
2940 |
} |
2941 |
} |
2785 |
/** |
2942 |
/** |
2786 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=178861 |
2943 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=178861 |
2787 |
*/ |
2944 |
*/ |