Commits

Anonymous committed bf29195

Fixes OGNL-18.

Array/List/etc accessors weren't properly detecting object vs primitive types when accessing their respective properties because ASTConst was still sticking the old object class type as the current context type. This involved refactoring ASTConst to correctly place the native type for numerics as well as fixing all the problems resulting from this new behavior.

Comments (0)

Files changed (12)

   </component>
   <component name="ChangeListManager">
     <list default="true" name="Default" comment="">
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Messages.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/ASTPropertyTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/ASTPropertyTest.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/StaticsAndConstructorsTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/StaticsAndConstructorsTest.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/OgnlTestCase.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/OgnlTestCase.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayElementsTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayElementsTest.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/IndexAccessTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/IndexAccessTest.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTConst.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTConst.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/PrimitiveArrayTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/PrimitiveArrayTest.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTList.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTList.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" afterPath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTRemainder.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTRemainder.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ArrayPropertyAccessor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ArrayPropertyAccessor.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTCtor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTCtor.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java" afterPath="$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/OGNL.iws" afterPath="$PROJECT_DIR$/OGNL.iws" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/SimpleNavigationChainTreeTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/SimpleNavigationChainTreeTest.java" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/MenuItem.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayCreationTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayCreationTest.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTMethod.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTMethod.java" />
     </list>
   </component>
   <component name="ChangesViewManager" flattened_view="true" />
           <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
         </PATH_ELEMENT>
       </PATH>
+      <PATH>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="OGNL.ipr" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+        </PATH_ELEMENT>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="OGNL" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
+        </PATH_ELEMENT>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+        </PATH_ELEMENT>
+      </PATH>
     </subPane>
   </component>
   <component name="ProjectReloadState">
       <showLibraryContents />
       <hideEmptyPackages />
       <abbreviatePackageNames />
-      <showStructure Scope="false" ProjectPane="false" PackagesPane="false" Favorites="false" />
+      <showStructure PackagesPane="false" ProjectPane="false" Scope="false" Favorites="false" />
       <autoscrollToSource />
       <autoscrollFromSource />
       <sortByType />
   </component>
   <component name="RecentsManager" />
   <component name="RestoreUpdateTree" />
-  <component name="RunManager" selected="JUnit.ASTPropertyTest">
-    <tempConfiguration default="false" name="ASTPropertyTest" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
+  <component name="RunManager" selected="JUnit.ArrayCreationTest">
+    <tempConfiguration default="false" name="ArrayCreationTest" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
       <pattern value="org.ognl.test.*" />
       <module name="OGNL" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
       <option name="ALTERNATIVE_JRE_PATH" />
       <option name="PACKAGE_NAME" value="org.ognl.test" />
-      <option name="MAIN_CLASS_NAME" value="org.ognl.test.ASTPropertyTest" />
+      <option name="MAIN_CLASS_NAME" value="org.ognl.test.ArrayCreationTest" />
       <option name="METHOD_NAME" />
       <option name="TEST_OBJECT" value="class" />
       <option name="VM_PARAMETERS" />
         <option name="Make" value="true" />
       </method>
     </tempConfiguration>
+    <configuration default="true" type="Remote" factoryName="Remote">
+      <option name="USE_SOCKET_TRANSPORT" value="true" />
+      <option name="SERVER_MODE" value="false" />
+      <option name="SHMEM_ADDRESS" value="javadebug" />
+      <option name="HOST" value="localhost" />
+      <option name="PORT" value="5005" />
+    </configuration>
+    <configuration default="true" type="Applet" factoryName="Applet">
+      <module name="" />
+      <option name="MAIN_CLASS_NAME" />
+      <option name="HTML_FILE_NAME" />
+      <option name="HTML_USED" value="false" />
+      <option name="WIDTH" value="400" />
+      <option name="HEIGHT" value="300" />
+      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
+      <option name="VM_PARAMETERS" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+    </configuration>
+    <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
+      <option name="MAIN_CLASS_NAME" />
+      <option name="VM_PARAMETERS" />
+      <option name="PROGRAM_PARAMETERS" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <option name="ENABLE_SWING_INSPECTOR" value="false" />
+      <module name="" />
+    </configuration>
     <configuration default="true" type="TestNG" factoryName="TestNG" enabled="false" merge="false">
       <module name="" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
         <option name="Make" value="true" />
       </method>
     </configuration>
-    <configuration default="true" type="Remote" factoryName="Remote">
-      <option name="USE_SOCKET_TRANSPORT" value="true" />
-      <option name="SERVER_MODE" value="false" />
-      <option name="SHMEM_ADDRESS" value="javadebug" />
-      <option name="HOST" value="localhost" />
-      <option name="PORT" value="5005" />
-    </configuration>
-    <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
-      <option name="MAIN_CLASS_NAME" />
-      <option name="VM_PARAMETERS" />
-      <option name="PROGRAM_PARAMETERS" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
-      <option name="ALTERNATIVE_JRE_PATH" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <module name="" />
-    </configuration>
     <configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
       <module name="" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
         <option name="Make" value="true" />
       </method>
     </configuration>
-    <configuration default="true" type="Applet" factoryName="Applet">
-      <module name="" />
-      <option name="MAIN_CLASS_NAME" />
-      <option name="HTML_FILE_NAME" />
-      <option name="HTML_USED" value="false" />
-      <option name="WIDTH" value="400" />
-      <option name="HEIGHT" value="300" />
-      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
-      <option name="VM_PARAMETERS" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
-      <option name="ALTERNATIVE_JRE_PATH" />
-    </configuration>
     <configuration default="true" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Remote">
       <option name="WORKING_DIRECTORY" />
       <option name="HOST" value="localhost" />
     <option name="PERFORM_COMMIT_IN_BACKGROUND" value="false" />
     <option name="PUT_FOCUS_INTO_COMMENT" value="false" />
     <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
-    <option name="LAST_COMMIT_MESSAGE" value="Fixes OGNL-17. ...Too much to list, the summary is that ASTCtor / ASTList hadn't had the same kind of context/ refactoring love &#10;that ASTMethod/ property/ etc had ...." />
+    <option name="LAST_COMMIT_MESSAGE" value="Fixes OGNL-18.&#10;&#10;Array/List/etc accessors weren't properly detecting object vs primitive types when accessing their respective properties because ASTConst was still sticking the old object class type as the current context type. This involved refactoring ASTConst to correctly place the native type for numerics as well as fixing all the problems resulting from this new behavior." />
     <option name="SAVE_LAST_COMMIT_MESSAGE" value="true" />
     <option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8" />
     <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
     <option name="UPDATE_GROUP_BY_PACKAGES" value="false" />
     <option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
     <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
-    <MESSAGE value="Fixes OGNL-9. ASTMethod wasn't handling the case where the incoming value being passed as a param was a primitive. Simplified logic by using the javassist widening conversion variable cast." />
     <MESSAGE value="Added svn:ignores for build/target/etc.." />
     <MESSAGE value="Added another static reference test for OGNL-12. Wasn't able to re-produce but will keep the test anyways &quot;just in case&quot;." />
     <MESSAGE value="FIxes OGNL-12 as I was able to find a failure when static methods / fields are involved." />
     <MESSAGE value="Minor code formatting / cleanup." />
     <MESSAGE value="Partially fixes OGNL-17 . It's only partial because someone tried to sneak in two different tickets under one." />
     <MESSAGE value="Fixes OGNL-17. ...Too much to list, the summary is that ASTCtor / ASTList hadn't had the same kind of context/ refactoring love &#10;that ASTMethod/ property/ etc had ...." />
+    <MESSAGE value="Fixes OGNL-18.&#10;&#10;Array/List/etc accessors weren't properly detecting object vs primitive types when accessing their respective properties because ASTConst was still sticking the old object class type as the current context type. This involved refactoring ASTConst to correctly place the native type for numerics as well as fixing all the problems resulting from this new behavior." />
   </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
     <option name="myLastEditedConfigurable" />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/OgnlTestCase.java">
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="179" column="0" selection-start="6941" selection-end="6941" vertical-scroll-proportion="0.5081967">
+        <state line="46" column="46" selection-start="2412" selection-end="2412" vertical-scroll-proportion="0.19165248">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayElementsTest.java">
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTMethod.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="62" column="6" selection-start="3100" selection-end="3100" vertical-scroll-proportion="0.31942078">
+        <state line="360" column="69" selection-start="13843" selection-end="13843" vertical-scroll-proportion="0.43781942">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/SetterTest.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="73" column="6" selection-start="3876" selection-end="3876" vertical-scroll-proportion="0.47274277">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ArrayPropertyAccessor.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="172" column="0" selection-start="6671" selection-end="6671" vertical-scroll-proportion="0.47614992">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="174" column="9" selection-start="6550" selection-end="6550" vertical-scroll-proportion="0.65456676">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Simple.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="80" column="0" selection-start="2781" selection-end="2781" vertical-scroll-proportion="0.5081967">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTConst.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="168" column="0" selection-start="5795" selection-end="5795" vertical-scroll-proportion="1.14637">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/MethodWithConversionTest.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="50" column="6" selection-start="2455" selection-end="2455" vertical-scroll-proportion="0.25553662">
+        <state line="49" column="0" selection-start="2448" selection-end="2448" vertical-scroll-proportion="0.2427598">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/OgnlOps.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="876" column="0" selection-start="32370" selection-end="32370" vertical-scroll-proportion="0.42037472">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTRemainder.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="70" column="12" selection-start="2705" selection-end="2705" vertical-scroll-proportion="0.54332554">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="168" column="47" selection-start="7360" selection-end="7360" vertical-scroll-proportion="0.6260647">
+        <state line="156" column="6" selection-start="7004" selection-end="7004" vertical-scroll-proportion="1.367121">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Simple.java">
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="72" column="0" selection-start="2569" selection-end="2569" vertical-scroll-proportion="0.38641685">
+        <state line="257" column="0" selection-start="10350" selection-end="10350" vertical-scroll-proportion="0.4335605">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ArrayCreationTest.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="60" column="6" selection-start="3196" selection-end="3196" vertical-scroll-proportion="0.35775128">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTMethod.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="223" column="79" selection-start="7561" selection-end="7782" vertical-scroll-proportion="0.6498829">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="1943" column="0" selection-start="74117" selection-end="74117" vertical-scroll-proportion="0.25526932">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/StaticsAndConstructorsTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="43" column="12" selection-start="2102" selection-end="2102" vertical-scroll-proportion="0.15332198">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="96" column="163" selection-start="6114" selection-end="6114" vertical-scroll-proportion="0.6516184">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/PrimitiveArrayTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="40" column="12" selection-start="2033" selection-end="2033" vertical-scroll-proportion="0.12776831">
+        <state line="29" column="77" selection-start="1724" selection-end="1724" vertical-scroll-proportion="0.0">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTCtor.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="241" column="25" selection-start="9233" selection-end="9233" vertical-scroll-proportion="2.0860307">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTList.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="182" column="35" selection-start="6754" selection-end="6754" vertical-scroll-proportion="0.93611586">
+        <state line="230" column="0" selection-start="8503" selection-end="8503" vertical-scroll-proportion="0.3483816">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="385" column="0" selection-start="14730" selection-end="14730" vertical-scroll-proportion="0.42078364">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ASTPropertyTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="50" column="8" selection-start="1490" selection-end="1490" vertical-scroll-proportion="0.57495743">
+        <state line="381" column="10" selection-start="14574" selection-end="14574" vertical-scroll-proportion="0.4088586">
           <folding />
         </state>
       </provider>

src/java/ognl/ASTConst.java

             return "";
         
         _getterClass = value.getClass();
+
         context.setCurrentType(value.getClass());
         context.setCurrentObject(value);
         
         } else if (_parent == null || !ASTProperty.class.isInstance(_parent))
             context.setCurrentType(_getterClass);
         
-        /* if (_parent == null && Number.class.isAssignableFrom(value.getClass())) {
-            
-            if (BigInteger.class.isInstance(value)) {
-                
-                return "new java.math.BigInteger(\"" + value + "\")";
-            }
-            
-            Class clazz = value.getClass();
-            if (clazz.isPrimitive())
-                clazz = OgnlRuntime.getPrimitiveWrapperClass(value.getClass());
-            
-            return "new " + clazz.getName() + "(" + OgnlRuntime.getNumericCast(value.getClass()) + value +")";
-        } else  if (Number.class.isAssignableFrom(value.getClass()) && OgnlRuntime.getNumericLiteral(value.getClass()) != null) {
-            
-            return value.toString() + OgnlRuntime.getNumericLiteral(value.getClass());
-        } else */ if (!(_parent != null 
+        if (!(_parent != null
                 && NumericExpression.class.isAssignableFrom(_parent.getClass()))
                 && String.class.isAssignableFrom(value.getClass())) {
             
         
         if (Boolean.class.isAssignableFrom(value.getClass()))
             _getterClass = Boolean.TYPE;
-        
-        context.setCurrentType(value.getClass());
+
+        if (Number.class.isAssignableFrom(value.getClass())) {
+            context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(value.getClass()));
+        } else
+            context.setCurrentType(value.getClass());
+
+        //context.setCurrentType(value.getClass());
         context.setCurrentObject(value);
 
         return value.toString();

src/java/ognl/ASTCtor.java

 
                         if (!ASTConst.class.isInstance(_children[i]))
                             value = cast + value;
-                        
-                        if (ASTConst.class.isInstance(_children[i]) && Number.class.isAssignableFrom(context.getCurrentType())) {
+
+                        if (context.getCurrentType().isPrimitive()) {
                             
-                            value += OgnlRuntime.getNumericLiteral(context.getCurrentType());
-                        } else if (objValue != null && !objValue.getClass().isPrimitive()
+                            String literal = OgnlRuntime.getNumericLiteral(context.getCurrentType());
+                            if (literal != null)
+                                value += literal;
+                        }
+
+                        if (objValue != null && !objValue.getClass().isPrimitive()
                                    && !objValue.getClass().isArray() && !ASTConst.class.isInstance(_children[i])) {
-
+                            
                             value = "(" + OgnlRuntime.getCompiler().getInterfaceClass(objValue.getClass()).getName() + ")" + value;
-                        } else {
-
+                        } else if (!ASTConst.class.isInstance(_children[i]) 
+                                   || (ASTConst.class.isInstance(_children[i]) && !context.getCurrentType().isPrimitive())) {
+                            
                             value = " ($w) " + value;
                         }
-
+                        
                         result += value;
                     }
                 }

src/java/ognl/ASTRemainder.java

             
             String result = "ognl.OgnlOps.remainder(";
             
-            result += OgnlRuntime.getChildSource(context, target, _children[0]) + ", " + OgnlRuntime.getChildSource(context, target, _children[1]);
+            result += " ($w) " + OgnlRuntime.getChildSource(context, target, _children[0]) + ", ($w) " + OgnlRuntime.getChildSource(context, target, _children[1]);
             
             result += ")";
             

src/java/ognl/ArrayPropertyAccessor.java

 
     public String getSourceAccessor(OgnlContext context, Object target, Object index)
     {
+        String indexStr = (String) index;
+
+        // need to convert to primitive for list index access
+
+        if (!context.getCurrentType().isPrimitive()) {
+
+            indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType());
+        }
+
         context.setCurrentAccessor(target.getClass());
         context.setCurrentType(target.getClass().getComponentType());
         
-        return "[" + index + "]";
+        return "[" + indexStr + "]";
     }
 
     public String getSourceSetter(OgnlContext context, Object target, Object index)
     {
+        String indexStr = (String) index;
+
+        // need to convert to primitive for list index access
+
+        if (!context.getCurrentType().isPrimitive()) {
+
+            indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType());
+        }
+
         Class type = target.getClass().isArray() ? target.getClass().getComponentType() : target.getClass();
         
         context.setCurrentAccessor(target.getClass());
             
             Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(type);
             
-            return "[" + index + "]=((" + wrapClass.getName() + ")ognl.OgnlOps.convertValue($3," + wrapClass.getName()
+            return "[" + indexStr + "]=((" + wrapClass.getName() + ")ognl.OgnlOps.convertValue($3," + wrapClass.getName()
                     + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass);
         } else {
 
-            return "[" + index + "]=ognl.OgnlOps.convertValue($3," + type.getName() + ".class)";
+            return "[" + indexStr + "]=ognl.OgnlOps.convertValue($3," + type.getName() + ".class)";
         }
     }
 }

src/java/ognl/ListPropertyAccessor.java

         context.setCurrentAccessor(List.class);
         
         if (index instanceof String) {
+            
             String key = ((String)index).replaceAll("\"", "");
             if (key.equals("size")) {
                 context.setCurrentType(int.class);
                 }
             }
         }
-        
-        return ".get(" + index + ")";
+
+        String indexStr = (String) index;
+
+        // need to convert to primitive for list index access
+
+        if (!context.getCurrentType().isPrimitive()) {
+            
+            indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType());
+        }
+
+        return ".get(" + indexStr + ")";
     }
 
     public String getSourceSetter(OgnlContext context, Object target, Object index)
         if (index instanceof String) {
             return "";
         }
+
+        String indexStr = (String) index;
+
+        // need to convert to primitive for list index access
+
+        if (!context.getCurrentType().isPrimitive()) {
+
+            indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType());
+        }
         
-        return ".set(" + index + ", $3)";
+        return ".set(" + indexStr + ", $3)";
     }
 }

src/java/ognl/OgnlRuntime.java

 
     static {
         NUMERIC_LITERALS.put(Integer.class, "");
+        NUMERIC_LITERALS.put(Integer.TYPE, "");
         NUMERIC_LITERALS.put(Long.class, "l");
+        NUMERIC_LITERALS.put(Long.TYPE, "l");
         NUMERIC_LITERALS.put(BigInteger.class, "d");
         NUMERIC_LITERALS.put(Float.class, "f");
+        NUMERIC_LITERALS.put(Float.TYPE, "f");
         NUMERIC_LITERALS.put(Double.class, "d");
+        NUMERIC_LITERALS.put(Double.TYPE, "d");
         NUMERIC_LITERALS.put(BigInteger.class, "d");
         NUMERIC_LITERALS.put(BigDecimal.class, "d");
     }
 
             child.getValue(context, target);
         } catch (NullPointerException e) {
-            e.printStackTrace();
+            // e.printStackTrace();
         }
 
         String source = child.toGetSourceString(context, target);

src/java/ognl/enhance/ExpressionCompiler.java

         
         body = body.replaceAll("\\.\\.", ".");
         
-        //System.out.println("Setter Body: ===================================\n"+body);
+        // System.out.println("Setter Body: ===================================\n"+body);
         
         if (setterCode.indexOf("$3") < 0)
             setterCode = "";

src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java

 import junit.framework.TestSuite;
 
 import java.math.BigDecimal;
-import java.math.BigInteger;
 
 public class ArithmeticAndLogicalOperatorsTest extends OgnlTestCase
 {
             { "5+2H*3", Integer.valueOf(11) },
             { "(5+2H)*3", Integer.valueOf(21) },
             { "~1h", Integer.valueOf(~1) },
-            { "5h%2", BigInteger.valueOf(1) },
+            { "5h%2", Integer.valueOf(1) },
             { "5h<<2", Integer.valueOf(20) },
             { "5h>>2", Integer.valueOf(1) },
             { "5h>>1+1", Integer.valueOf(1) },
             { "#y == \"1\"", Boolean.TRUE },
             { "#y + \"1\"", "11" },
             { "\"1\" + #y", "11" }
-
     };
 
     /*

src/test/java/org/ognl/test/ArrayCreationTest.java

                     new Simple[] { new Simple(), new Simple("foo", 1.0f, 2) } },
             { ROOT, "new org.ognl.test.objects.Simple[5]", new Simple[5] },
             { ROOT, "new org.ognl.test.objects.Simple(new Object[5])", new Simple(new Object[5]) },
-            { ROOT, "new org.ognl.test.objects.Simple(new String[5])", new Simple(new String[5]) } 
+            { ROOT, "new org.ognl.test.objects.Simple(new String[5])", new Simple(new String[5]) }
     };
 
     /*

src/test/java/org/ognl/test/IndexAccessTest.java

 import ognl.MethodFailedException;
 import org.ognl.test.objects.Root;
 
-public class IndexAccessTest extends OgnlTestCase
-{
+public class IndexAccessTest extends OgnlTestCase {
 
     private static Root ROOT = new Root();
 
     private static Object[][] TESTS = {
             // indexed access of with navigation chain (should start back at root)
-            { ROOT, "list[index]", ROOT.getList().get(ROOT.getIndex()) },
-            { ROOT, "list[size() - 1]", MethodFailedException.class },
-            { ROOT, "(index == (array.length - 3)) ? 'toggle toggleSelected' : 'toggle'", "toggle toggleSelected"},
-            { ROOT, "\"return toggleDisplay('excdisplay\"+index+\"', this)\"", "return toggleDisplay('excdisplay1', this)"}
+            {ROOT, "list[index]", ROOT.getList().get(ROOT.getIndex())},
+            {ROOT, "list[objectIndex]", ROOT.getList().get(ROOT.getObjectIndex().intValue())},
+            {ROOT, "array[objectIndex]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] },
+            {ROOT, "list[size() - 1]", MethodFailedException.class},
+            {ROOT, "(index == (array.length - 3)) ? 'toggle toggleSelected' : 'toggle'", "toggle toggleSelected"},
+            {ROOT, "\"return toggleDisplay('excdisplay\"+index+\"', this)\"", "return toggleDisplay('excdisplay1', this)"}
     };
 
     /*
     {
         TestSuite result = new TestSuite();
 
-        for(int i = 0; i < TESTS.length; i++) {
+        for (int i = 0; i < TESTS.length; i++) {
             result.addTest(new IndexAccessTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2]));
         }
         return result;

src/test/java/org/ognl/test/objects/Root.java

     private BeanProvider _beanProvider = new BeanProviderImpl();
     private boolean _render;
     private Boolean _readOnly = Boolean.FALSE;
+    private Integer _objIndex = new Integer(1);
 
     /*===================================================================
 		Public static methods
         return index;
     }
 
+    public Integer getObjectIndex()
+    {
+        return _objIndex;
+    }
+
     public int getIntValue()
     {
         return intValue;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.