Ranbir Singh was the Maharaja of Kashmir when the Indian Penal Code, 1860 was passed. So, he adopted the same as Ranbir Penal Code in state of Jammu and Kashmir.
Article 370 gives autonomy to State of J&K to adopt make any law or change the name of any law. And naturally for sentimental reasons they are not going to do it.
If one sees, Indian Penal Code, Pakistan Penal Code, Penal Code, 1860: Bangladesh and Ranbir Penal Code they are all the same.