Clojure

deftype does not work if containing ns contains dashes

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • 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)

Activity

Hide
Alex Miller added a comment -

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.

Show
Alex Miller added a comment - 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.
Hide
Laurent Petit added a comment -

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

Show
Laurent Petit added a comment - OK, I've tested the patch and it works. The correction seems straightforward, too.
Hide
Chas Emerick added a comment -

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

Show
Chas Emerick added a comment - This patch fixes namespace munging for protocols, deftype, and defrecord.
Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/432

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: