<< Back to previous view

[CLJ-432] deftype does not work if containing ns contains dashes Created: 08/Sep/10  Updated: 13/Mar/11  Resolved: 29/Nov/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Defect Priority: Major
Reporter: Laurent Petit Assignee: Chas Emerick
Resolution: Completed Votes: 0
Labels: None

Attachments: File CLJ-432.diff    
Patch: Code and Test
Approval: Ok

 Description   

There's a problem with the compilation (either live or AOT) of e.g. types, if the namespace containing the type definition cointains dashes.

It's quite easy to reproduce: create src/net/yournick/lr_plus.clj , and in this file, have just "(ns net.yournick.lr-plus) (deftype Foo)"
AOT compile this, and shebang! in your classes/ directory you see the following folder structure: classes/net/yournick/lr-plus/

lr-plus/ contains the Foo.class file

folder lr-plus/ should really be lr_plus/

the problem is that while apparently with Oracle JVMs everything works fine while you don't try to AOT compile it, it does not work (even if not AOT'ed) with IBM JRE 6:

Caused by: java.lang.ClassFormatError: JVMCFRE068 class name is invalid; class=compile__stub/net/cgrand/parsley/lr-plus/TableState, offset=0 (lr_plus.clj:8)



 Comments   
Comment by Assembla Importer [ 08/Oct/10 7:35 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/432

Comment by Chas Emerick [ 19/Nov/10 9:23 PM ]

This patch fixes namespace munging for protocols, deftype, and defrecord.

Comment by Laurent Petit [ 21/Nov/10 6:45 AM ]

OK, I've tested the patch and it works.
The correction seems straightforward, too.

Comment by Alex Miller [ 13/Mar/11 11:54 PM ]

This was a breaking change for us in 1.2.1 in this kind of example:

(ns my.rec-test
  (:use [clojure.test]))

(defrecord Foo [a])

(deftest test-rec 
  ;; 1.2.0 should use my.rec-test.Foo
  ;; 1.2.1 should use my.rec_test.Foo
  (is (= my.rec-test.Foo (class (Foo. 1)))))

Dropping a note here in case others run into it.

Generated at Sun Nov 23 23:39:26 CST 2014 using JIRA 4.4#649-r158309.